com.pelzer.util
Class PasswordCrypt

java.lang.Object
  extended by com.pelzer.util.PasswordCrypt

public class PasswordCrypt
extends Object


Constructor Summary
PasswordCrypt()
           
 
Method Summary
static String computePasswordHash(String password, byte[] salt)
          Uses PBKDF2WithHmacSHA1 to hash the password using the given salt, returning the has in encoded hexadecimal form.
static String computePasswordHash(String password, String salt)
          Converts the salt into a byte array using stringToSalt(String) and then calls computePasswordHash(String, byte[])
static byte[] generateRandomSalt()
          Generates a random byte array to be used as a salt for computePasswordHash(String, byte[])
static byte[] stringToSalt(String string)
          Uses SHA-1 to hash the given string and returns the byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PasswordCrypt

public PasswordCrypt()
Method Detail

computePasswordHash

public static String computePasswordHash(String password,
                                         String salt)
Converts the salt into a byte array using stringToSalt(String) and then calls computePasswordHash(String, byte[])


computePasswordHash

public static String computePasswordHash(String password,
                                         byte[] salt)
Uses PBKDF2WithHmacSHA1 to hash the password using the given salt, returning the has in encoded hexadecimal form. If the password is empty, returns the salt.


generateRandomSalt

public static byte[] generateRandomSalt()
Generates a random byte array to be used as a salt for computePasswordHash(String, byte[])


stringToSalt

public static byte[] stringToSalt(String string)
Uses SHA-1 to hash the given string and returns the byte array.



Copyright © 2012. All Rights Reserved.