Package de.intarsys.tools.authenticate
Class PasswordTools
java.lang.Object
de.intarsys.tools.authenticate.PasswordTools
A tool class for handling passwords and authentication
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic char[]createRandom(int length) Create a random password of lengthlength.static byte[]decrypt(byte[] bytes) Decrypt a byte array which was previously encrypted usingencrypt.static char[]Decrypt a string which was previously encrypted usingencrypt.static byte[]encrypt(byte[] bytes) Encrypt a clear text array of bytes.static Stringencrypt(char[] value) Encrypt a clear text array of chars.static Stringhash(char[] password) A one way hash for a clear text password.static voidinitialize(byte[] salt, char[] passphrase) Initialize thePasswordTools.
-
Constructor Details
-
PasswordTools
public PasswordTools()
-
-
Method Details
-
createRandom
public static char[] createRandom(int length) Create a random password of lengthlength.- Parameters:
length-- Returns:
- A new random password.
-
decrypt
public static byte[] decrypt(byte[] bytes) Decrypt a byte array which was previously encrypted usingencrypt. Provided the same salt and passphrase are used for initialization, this method returns the original unencrypted input.- Parameters:
bytes-- Returns:
- The decrypted representation of
bytes
-
decrypt
Decrypt a string which was previously encrypted usingencrypt. Provided the same salt and passphrase are used for initialization, this method returns the original unencrypted input.- Parameters:
value-- Returns:
- The decrypted representation of
value
-
encrypt
public static byte[] encrypt(byte[] bytes) Encrypt a clear text array of bytes. The result is the plain encrypted byte array.- Parameters:
bytes-- Returns:
- The encrpyted representation of
bytes
-
encrypt
Encrypt a clear text array of chars. The result is a Base64 encoded string version of the encrypted UTF-8 encoded input bytes.- Parameters:
value-- Returns:
- An encrypted, invertible representation of
value
-
hash
A one way hash for a clear text password.- Parameters:
password-- Returns:
- A one way hash for a clear text password.
-
initialize
public static void initialize(byte[] salt, char[] passphrase) Initialize thePasswordTools.- Parameters:
salt-passphrase-
-