Generating Random Alpha numeric Salt String using MD5 or other algorithm

Hello,
I have a requirement where i need to generate a random alpha numeric salt for MD5 algorithm. Is there a best way to generate this salt ?
The alpha numerics should confine to 5 digits with possible values for each digit being (a-z), (0-9), (A-Z).
Any good random generator for salt would be appreciated.
Thanks.

Hi there,
I think the book you read is the book "Java Security", I have that one too.
Please read all those pages before this code.........
In this code, it used the RSA algorithm to do the encryption and JDK DOES NOT support
RSA algorithm....
Beside, this line
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA", "BC");It implies the BouncyCastle security provider is in use.... so
www.bouncycastle.org might be a good place to start with....
Good luck!

Similar Messages

  • Random alpha numeric generation.

    i have a requiremnt where i need to generate a random alpha numeric values with the combination of
    a - z (lower case)
    A - Z (Upper case)
    0-9
    with out using the dbms_random.string
    please help me to get the complete script
    Prashant K

    i used dbms_random.string('X',6) statement but it generates the alphanumeric with upper case. i wanted the combination of lower,upper and digits. as shown below.
    e.g aB3cdFE88
    to get the above i did some thing like this.
    select dbms_random.string('L',4)||dbms_random.string('X',6) as rand_alphanumeric from dual
    here i am concatinating the two strings.
    i want to know is there any way other than this to geneate random alphanumeric values ?

  • How to generate password alpha numeric value

    dear friends,
    i have written a simple pl/sql to generate a password.
    declare
    cursor c1 is select * from passwd;
    begin
    for I in c1
    loop
    if I.pfno < 3000 then
    update passwd set pwd=I.pfno where i.pfno=pfno;
    ELSe
    update passwd set pwd=lpad(round(I.pfno/20520),4,'0') where i.pfno=pfno;
    commit;
    end if;
    end loop;
    end;
    In this the pfno is 8 digit alpha numeric. I get password generated when it is only numeric but how could i get if pfno is like 04MAS155.
    Kindly help as i have to generate the same as early as possible. I have already been given with procedure to generate random password by our guys but still as i had already generated password to some employees in my concern based on querries like above i request your help to generate for alpha numeric 8 digit number.

    -- get a random string
        FUNCTION string (opt char, len NUMBER)
              /* "opt" specifies that the returned string may contain:
                 'u','U'  :  upper case alpha characters only
                 'l','L'  :  lower case alpha characters only
                 'a','A'  :  alpha characters only (mixed case)
                 'x','X'  :  any alpha-numeric characters (upper)
                 'p','P'  :  any printable characters
            RETURN VARCHAR2;  -- string of <len> characters (max 60)
        PRAGMA restrict_references (string, WNDS);

  • How to generate random numbers in a range using random class?

    I know how to use Math.random for this, but how would I generate random numbers using the random class?
    Say I want a number between 40 and 50, inclusive--how would I do this?
    What i have in mind is:
    int randomNumber = random.nextInt(max) + min;
    where max is 50 and min is 40. Is this correct?

    Fredddir_Java wrote:
    I know how to use Math.random for this, but how would I generate random numbers using the random class?
    Say I want a number between 40 and 50, inclusive--how would I do this?
    What i have in mind is:
    int randomNumber = random.nextInt(max) + min;
    where max is 50 and min is 40. Is this correct?What happened when you generated a couple hundred numbers that way? Did you get all the ints in the range you wanted?

  • Konify3D: generate random(ish) 3D desktop backgrounds using povray

    Some of you might remember konify. This is a 3D version of it using povray.
    I've created a page for this on my site (in the "Other Stuff" area): http://xyne.archlinux.ca/artwork/konify3d
    You can get the latest version of the povray file that I'm using there. I've tried to arrange "options" near the top of the file and most of them will hopefully be self-explanatory (e.g. Aspect_Ratio).
    Here are some output examples. I haven't even begun to look into surface and texture settings yet so hopefully there will be more to come. There might be more examples on the page above because I can update that automatically.
    Post your own examples if you generate any.
    Examples
    Playing around with colors:
    Playing around with lights:
    Last edited by Xyne (2009-11-11 11:16:47)

    Very interesting! Here's my results:
    PS: discovered a minor mistake around line 228, which exchanges blue and green
    Last edited by lolilolicon (2009-11-10 09:41:41)

  • Extract the numbers in string using regex

    Hi,
    How to extract the numers in string using regex?.
    Already i tried split up the string using [\\s]
    For ex: "Uting Tatk and Window Panet 15"
    it gives the ans 15.
    if the string is
    For ex: "Uting Tatk and Window Panet 15 New!"
    i can't find the number.
    so plz give me some idea to get the number frm String.
    Thanks

    I am developing a java project to extract Table of
    content in a particular
    PDF.
    i extracted all topics.
    then i want 2 extract page number from dat extracted
    TOC.
    if the TOC ends with number then i can easily find
    out the number
    but in vain if the TOC ends with like this
    "Uting Tatk and Window Panet 15 New!".
    i could n't find the page number.What will you do if it says:
    "15 ways to find topics 42 new"

  • String to MD5 hex

    hi all, i need a way to convert a String to an MD5, to be more precise i need to get the MD5 string in hex. I have tried a few methods but they only seem to work 80% of the time, any help would be appriciated.
    note: i am storing values in a mysql db (just a test will try SHA later) when i put the data in the my sql i pass it as a string using MD5("myString")
    thanks

    Well i got it and it works perfectly in case any wants to now this is the code
    import java.security.MessageDigest;
    public class MD5Maker
         public static String makeMD5(String str){
              String MD5HexString = null;
              try{
                 byte[] intext = str.getBytes();
                 StringBuffer buf = new StringBuffer();
                 MessageDigest md5 = MessageDigest.getInstance("MD5");
                 byte[] md5bytes = md5.digest(intext);
                 for( int i = 0 ; i < md5bytes.length ; i++ ) {
                       int value = 0xff & ((int)md5bytes);
                   if (value < 16)
                        buf.append("0");
                   buf.append(Integer.toHexString(value));
                   MD5HexString = buf.toString();
              catch (Exception e) {}
              return MD5HexString;

  • How to encrypt password using md5

    Hello all,
    I would like to generate a password and encrypt it using md5 with the current time(System's time) as the key, in Servlets.
    How do i go about doing this?
    Kindly guide.
    regards
    appu

    >
    I would like to generate a password and encrypt it
    using md5 MD5 is a non-reversible hashing, not an encryption!
    with the current time(System's time) as the
    key, If you use the current system time as the key for any encryption algorithm then how are you going to know what system time to use to decrypt?
    in Servlets.
    How do i go about doing this?Read up on encryption, the JCE and Servlets.

  • How do I copy/paste full numerical-only account strings into the Projects WebADI template when the account segment fields in the template require use of the dropdown because they're formatted as alpha-numeric values?

    How do I copy/paste full numerical-only account strings into the Projects WebADI template when the account segment fields in the template require use of the dropdown because they're formatted as alpha-numeric values? I'm using the Integrator named "Projects - Transaction Import" and a custom Layout created based on the seeded Layout named "Transaction Import - Accounted". Do I need to somehow change my Layout to make the Document accept numerical values instead of requiring alpha-numeric values? I need to be able to populate the Document with a large amount of transactions and cannot feasibly go through every transaction to add the alpha-valued name of the account segment to every segment that requires it. The segments in particular causing the problem are "Expnd Type" and "Organization Name" which are both alpha-numeric and as such contain the segment number and name; I need to be able to only have to enter the Natural Account Number (6-digit number only) and the Organization Number (5-digit number only).

    How do I copy/paste full numerical-only account strings into the Projects WebADI template when the account segment fields in the template require use of the dropdown because they're formatted as alpha-numeric values? I'm using the Integrator named "Projects - Transaction Import" and a custom Layout created based on the seeded Layout named "Transaction Import - Accounted". Do I need to somehow change my Layout to make the Document accept numerical values instead of requiring alpha-numeric values? I need to be able to populate the Document with a large amount of transactions and cannot feasibly go through every transaction to add the alpha-valued name of the account segment to every segment that requires it. The segments in particular causing the problem are "Expnd Type" and "Organization Name" which are both alpha-numeric and as such contain the segment number and name; I need to be able to only have to enter the Natural Account Number (6-digit number only) and the Organization Number (5-digit number only).

  • Unique random alpha num string

    Hi Guys,
    I have a unique question.
    I need to generate a unique random Alpha Num string.
    I cannot use 0,5,8 and 0,S,B in the generated output string.
    The string generated should be no more than length 7 max
    Pls help.

    Following solution generates random unique strings combinations
    from any given base set. Here is a sample output.
    $ java UniqueStringGenerator 7 100 10
    FCT2RYT
    2M31BU8
    VV8FU4Z
    BON2MKE
    OKUJZT0
    68E8X8S
    YTNLZAY
    CPEKPFP
    C176M24
    GQB9QE9The idea is quite simple.
    Pre-work:
    1. The base set is first mixed to increase entropy.
    2. All possible combinations are divide up into random buckets.
    Work for every unique string:
    1. Pick a bucket at random.
    2. Get next number in bucket.
    3. Convert the number to a unique string token.
    It is possible to adjust how much entropy you want in your
    sequence of generated combinations by choosing how many buckets
    the generator contains. However, every bucket will take up some
    memory.
    import java.util.*;
    import java.math.*;
    public class UniqueStringGenerator {
        public static String[] ALPHA_NUM =
         {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P",
          "Q","R","S","T","U","V","X","Y","Z",
          "0","1","2","3","4","5","6","7","8","9"};
        private List _parts = null;
        private List _buckets = null;
        private int _length;
        private BigInteger _range = null;
        public UniqueStringGenerator(String[] parts, int length,
                         int numberOfBuckets) {
         _length = length;
         // mixing the base set to increase entropy
         _parts = new Vector();
         List all = new Vector();
         for (int i = 0;i < parts.length;i++) {
             all.add(parts);
         while (all.size()>0) {
         int p = (int)(((double)all.size())*Math.random());
         _parts.add(all.get(p));
         all.remove(p);
         // dividing all possible numbers into given number of buckets
         BigInteger numParts = BigInteger.valueOf(parts.length);
         _range = BigInteger.ONE;
         for (int i = 0;i<_length;i++) {
         range = range.multiply(numParts);
         TreeSet starts = new TreeSet();
         Random rand = new Random();
         while (starts.size()<numberOfBuckets-1) {
         BigInteger bi = new BigInteger(_range.bitLength(), rand);
         if (bi.compareTo(_range)<=0) {
              starts.add(bi);
         _buckets = new Vector();
         Bucket last = new Bucket(BigInteger.ZERO);
         _buckets.add(last);
         for (Iterator i = starts.iterator();i.hasNext();) {
         Bucket next = new Bucket((BigInteger)i.next());
         _buckets.add(next);
         last.setTo(next.getStart());
         last = next;
         last.setTo(_range);
    private class Bucket {
         private BigInteger _start;
         private BigInteger _next;
         private BigInteger _to;
         public Bucket(BigInteger start) {
         _start = start;
         _next = start;
         public void setTo(BigInteger to) {
         _to = to;
         public BigInteger getStart() {
         return _start;
         public boolean hasNext() {
         return next.compareTo(to)<0;
         public BigInteger next() {
         BigInteger ret = _next;
         next = next.add(BigInteger.ONE);
         return ret;
         public String toString() {
         return "["+start+", "+next+", "+_to+"]:"+hasNext();
    public String nextUnique() {
         // getting next big integer
         BigInteger left = null;
         while (left==null) {
         Bucket b = (Bucket)
              buckets.get((int)(Math.random()*buckets.size()));
         if (b.hasNext()) {
              left = b.next();
         // converting it to a combination
         StringBuffer unique = new StringBuffer();
         BigInteger base = BigInteger.valueOf(_parts.size());
         for (int i = 0;i<_length;i++) {
         BigInteger[] resRem = left.divideAndRemainder(base);
         left = resRem[0];
         unique.append(_parts.get(resRem[1].intValue()));
         return unique.toString();
    public static void main(String[] args) {
         if (args.length!=3) {
         System.out.println("Usage: UniqueStringGenerator "+
                   "[string size] [# buckets] [# prints]");
         return;
         int length = Integer.parseInt(args[0]);
         int numBuckets = Integer.parseInt(args[1]);
         int num = Integer.parseInt(args[2]);
         UniqueStringGenerator usg = new UniqueStringGenerator
         (UniqueStringGenerator.ALPHA_NUM, length, numBuckets);
         for (int i=0;i<num;i++) {
         System.out.println(usg.nextUnique());

  • Using MD5 to generate Dimension IW Keys

    Hi Guys
    I had wanted to use MD5 to hash concatenated strings in a dimension table to come up with IW Keys. I must be missing something because I couldn't find much around the net when looking for it.
    Basically were looking at facts and dimension data in Star Schema. Now typically in a star schema for each dimension we generate an IW Key which we store in the fact to link the two:
    So a region table might look like:
    Region=IW Key
    A=1
    B=2
    c=3
    And A fact table would be like
    RegionIWKey,Metric1,Metric2
    1,3.0,4.0
    2,3.0,4.1
    3,3.0,4.0
    1,3.2,4.3
    Now to load the fact we need to load the dimensions first and then get the IW key, and this takes a lot of time.
    After all that here's the question?
    Why couldn't we just hash the dimension fields to get an IW Key then we could load facts and dimesnions in parallel.
    My understanding is that an MD5 Hash should do this, correct? Then we can index the hashed field. If I am missing something has anyone found out a way to do this successfully and get hashes with no collisions.
    Thanks for light anyone could shed on this.

    http://forum.java.sun.com/thread.jsp?forum=31&thread=225812

  • TS3276 I need feedback for the following issue. When I send email from this 27 inch iMac, the computer adds a string of characters in vertical column that represents the QWERTY key board, all alpha numeric characters are included. Yahoo mail, issue only o

    Restating my issue / question...
    When I send email from this iMac, there is a string of characters assigned. The characters are all the "alpha numeric" characters on the QWERTY key board. This only occurs when email is sent from this iMac. The issue does not manifest when using any other lap top or computer.
    Hence, I have ruled out the issue is a yahoo mail matter.
    Again, I can access the Yahoo mail account form multiple devices and send email without unintended assignment of character strings, but when I send wmail using this iMac, the issue happens everytime.
    Characters are stacked verticaly in a column. It looks as if all characters (except function keys) are included in the string.
    Any ideas?
    GMc

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It won’t solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    Third-party system modifications are a common cause of usability problems. By a “system modification,” I mean software that affects the operation of other software — potentially for the worse. The following procedure will help identify which such modifications you've installed. Don’t be alarmed by the complexity of these instructions — they’re easy to carry out and won’t change anything on your Mac. 
    These steps are to be taken while booted in “normal” mode, not in safe mode. If you’re now running in safe mode, reboot as usual before continuing. 
    Below are instructions to enter some UNIX shell commands. The commands are harmless, but they must be entered exactly as given in order to work. If you have doubts about the safety of the procedure suggested here, search this site for other discussions in which it’s been followed without any report of ill effects. 
    Some of the commands will line-wrap or scroll in your browser, but each one is really just a single line, all of which must be selected. You can accomplish this easily by triple-clicking anywhere in the line. The whole line will highlight, and you can then copy it. The headings “Step 1” and so on are not part of the commands. 
    Note: If you have more than one user account, Step 2 must be taken as an administrator. Ordinarily that would be the user created automatically when you booted the system for the first time. The other steps should be taken as the user who has the problem, if different. Most personal Macs have only one user, and in that case this paragraph doesn’t apply. 
    Launch the Terminal application in any of the following ways: 
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.) 
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens. 
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid. 
    When you launch Terminal, a text window will open with a line already in it, ending either in a dollar sign (“$”) or a percent sign (“%”). If you get the percent sign, enter “sh” and press return. You should then get a new line ending in a dollar sign. 
    Step 1 
    Triple-click the line of text below to select it:
    kextstat -kl | awk '!/com\.apple/{printf "%s %s\n", $6, $7}' | open -f -a TextEdit 
    Copy the selected text to the Clipboard by pressing the key combination command-C. Then click anywhere in the Terminal window and paste (command-V). A TextEdit window will open with the output of the command. Post the contents of that window, if any — the text, please, not a screenshot. You can then close the TextEdit window. The title of the window doesn't matter, and you don't need to post that. No typing is involved in this step.
    Step 2 
    Repeat with this line:
    { sudo launchctl list | sed 1d | awk '!/0x|com\.(apple|openssh|vix)|org\.(amav|apac|cups|isc|ntp|postf|x)/{print $3}'; sudo defaults read com.apple.loginwindow LoginHook; } | open -f -a TextEdit 
    This time you'll be prompted for your login password, which you do have to type. Nothing will be displayed when you type it. Type it carefully and then press return. You may get a one-time warning to be careful. Heed that warning, but don't post it. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator. 
    Note: If you don’t have a login password, you’ll need to set one before taking this step. If that’s not possible, skip to the next step. 
    Step 3
    launchctl list | sed 1d | awk '!/0x|com\.apple|org\.(x|openbsd)/{print $3}' | open -f -a TextEdit 
    Step 4
    ls -1A /e*/mach* {,/}L*/{Ad,Compon,Ex,Fram,In,Keyb,La,Mail/Bu,P*P,Priv,Qu,Scripti,Servi,Spo,Sta}* L*/Fonts 2> /dev/null | open -f -a TextEdit  
    Important: If you formerly synchronized with a MobileMe account, your me.com email address may appear in the output of the above command. If so, anonymize it before posting. 
    Step 5
    osascript -e 'tell application "System Events" to get name of every login item' | open -f -a TextEdit 
    Remember, steps 1-5 are all copy-and-paste — no typing, except your password. Also remember to post the output. 
    You can then quit Terminal.

  • Removing non-alpha-numeric characters from a string

    How can I remove all non-alpha-numeric characters from a string? (i.e. only alpha-numerics should remain in the string).

    Or even without a loop ?
    Extract from the help for the Search and Replace String function :
    Right-click the Search and Replace String function and select Regular Expression from the shortcut menu to configure the function for advanced regular expression searches and partial match substitution in the replacement string.
    Extract from the for the advanced search options :
    [a-zA-Z0-9] matches any lowercase or uppercase letter or any digit. You also can use a character class to match any character not in a given set by adding a caret (^) to the beginning of the class. For example [^a-zA-Z0-9] matches any character that is not a lowercase or uppercase letter and also not a digit.
    Message Edité par JB le 05-06-2008 01:49 PM
    Attachments:
    Example_VI_BD4.png ‏2 KB

  • HOW TO GENERATE RANDOM MEANINGFUL STRINGS ?

    Friends,
    How do I generate random meningfull strings ? I know how to generate strings randomly but I want to generate meaningfull names. The length is not important. Please help me in this matter as I have to implement this soon.
    Thanks in advance
    Ankit.

    Thanks for reply,
    I want to generate any string randomly and also want to make sure that it is meaningfull name. I can use Random(0n class to generate random number then convert according to ascii table to char and concat these generated chars to have string but then it is not meaningfull string, it could be anything. I want the string to be meaningfull too.(any word or name in english language). I don't want to pick up already generated word or names from list randomly(i think this is what you are thinking)

  • Generate random alphanumeric string as pk

    Hallo,
    I want to generate a random and unique alphanumeric string (4-digit).
    Uniqueness is very important, because it will be used as primary key.
    Is this supported by oracle 10?

    You can try the sys_guid function:
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for Linux IA64: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    SQL> select sys_guid() from dual;
    SYS_GUID()
    439F46B40AAAFB59E04014ACAE650DC1
    SQL> create table guid_tbl(str varchar2(300), constraint guid_tbl_pk primary key
    (str));
    Table created.
    SQL> begin
      2  for i in 1..1000 loop
      3     insert into guid_tbl(str) values(sys_guid());
      4  end loop;
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    SQL> select count(*) from guid_tbl;
      COUNT(*)
          1000
    SQL>Amiel

Maybe you are looking for

  • HP Laserjet P1102 print  multiple pages - USB connected to Airport Extreme -

    Hello, My configuration is Windows Vista/7 - Bonjour Print - HP LaserJet P1102 USB connected to Airport Extreme. Everytime I sent a print job - it get printed endless times until I hit "Cancel" on the print queue. Help anyone.. Thank you very much, -

  • Can't get rid of stock photo when using iWeb but publishing to non-MobileMe

    On one of my pages I have a vertical column of photos with my photos from iPhoto that I dragged and dropped into iWeb. The page was originally based on an iWeb template, though I cannot remember which one. The problem I am having is that the stock ph

  • How i can Find primary key combination?

    Hi, I have small doubt how i can find primary key combination for a record in siebel application.( For example Opportunity list applet or Account list applet or etc.. what is the primary key combination and how i can find that combination for a parti

  • 10.1.0.3 Patchset Now Available

    The 10.1.0.3 patchset is now available on Metalink for Microsoft Windows and Intel Linux. From a brief glance at the rest of the platforms it doesn't appear to be out yet for the Unix platforms. Can anyone from Oracle let us know if there's any chang

  • Deleted Account in AAD

    I'm using Azure AD Connect Preview to sync our local AD to Azure AD.  I was trying to fix an issue I was having and I deleted an account that was in AAD.  I thought when Azure AD Connect would sync again it would create the account again in AAD, but