salting passwords

29 views
Skip to first unread message

steve

unread,
Mar 29, 2014, 6:28:40 AM3/29/14
to codenameone...@googlegroups.com
Hi,
im trying to create a salt for passwords that the user inputs, this is the method im using:
    private String saltCreation(){
       
         Random random=new SecureRandom();
        byte[] array=new byte[20];
        random.nextBytes(array);
       
        return Base64.encode(array);
    }
im using the SecureRandom from  javabc.SecureRandom;

When i try to run it i get the following error:
Registration.java:244: error: cannot find symbol
        random.nextBytes(array);
  symbol:   method nextBytes(byte[])
  location: variable random of type Random
 
When i look at the Class SecureRandom : SecureRandom.java I can see the function getBytes(byte[]):

Is there something that i am missing or is there another way to implement it?

Thanks in advance,
Steve

S. Dale Morrey

unread,
Mar 29, 2014, 7:15:29 AM3/29/14
to codenameone...@googlegroups.com, stephen...@gmail.com
You might see it, but you ain't calling it.  Look really, really closely at your code :D

stephen...@gmail.com

unread,
Mar 29, 2014, 10:45:57 AM3/29/14
to codenameone...@googlegroups.com, stephen...@gmail.com
hehe :) ...thanks Dale...it was my mistake the method should be like this:

private String saltCreation() {
        byte[] array = new byte[20];
        new SecureRandom().nextBytes(array);
        return Base64.encode(array);
    }

much appreciated...

Reply all
Reply to author
Forward
0 new messages