Friday, September 19, 2014

Password Crypt

Secure Password
---------------

Passwords are very critical and if stored in plain text can cause one of the security threats.
Anyone who gets access to the plain-text password will have access to all the things in the world.

There are various schemes available

At this point of time Sha-512 is one of the better known crypt algorithm in used and supported by various linux version.
- For linux box. Edit the /etc/default/passwd file. "CRYPT_FILES=sha512"
Now create a new user or reset the password of existing user
Open the /etc/passwd. You can see your password is saved in the new crypt format $6$salt$xxxxxxxxxxx

If you have your own authentication system developed in java you can use apache common crypt3 function.
apache crypt

import org.apache.commons.codec.digest.Crypt;

/*get the digest with salt*/
public static String getDigest(String password, String salt) {
  return Crypt.crypt(password, salt);
}
/*get the digest with default salt*/
public static String getDigest(String password) {
  return Crypt.crypt(password);
}

No comments:

Post a Comment