Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

salt before hash passwords

hash

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1 harleyquinn46

harleyquinn46

    CC Lurker

  • New Member
  • Pip
  • 8 posts

Posted 31 May 2016 - 02:34 PM

how do I salt a password before hashing it?

I just don't know how to do that.

----------------------------------------------------------------------------------------------

 

<private String hash(String username, String pw) {

 

String username = " ";

String password = "password";

String salt = "random names";

if(null == input){

return null;

}

try {

// TODO: salt the password before hashing

 

MessageDigest m = MessageDigest.getInstance("MD5");

m.update(input.getBytes(), 0, input.length());

BigInteger num = new BigInteger(1,m.digest());

return num.toString(16);

} catch (NoSuchAlgorithmException e) {

System.out.println(e.getMessage());

System.exit(1);

return "";

}>



#2 rohshall

rohshall

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 01 June 2016 - 05:11 PM

Just append the salt string to the password string before MD5 hashing it. 



#3 harleyquinn46

harleyquinn46

    CC Lurker

  • New Member
  • Pip
  • 8 posts

Posted 04 June 2016 - 05:25 PM

I still don't understand how to do it.