you can also consider passing the char[] to the String constructor, and encrypting it.
here's a method to do the encryption for you.
Code:
/**
* Returns the encrypted password.
*
* @param password
* @return The encrypted password.
*/
public static final String encrypt(String password) {
MessageDigest md;
String encryptedPass = null;
try {
md = MessageDigest.getInstance("SHA");
byte[] shaBytes = md.digest(password.
getBytes("UTF-8" ));
encryptedPass = new BigInteger(shaBytes).toString(16);
} catch (NoSuchAlgorithmException e) {
log.error(e);
} catch (UnsupportedEncodingException e) {
log.error(e);
}
return encryptedPass;
}
Usage : encryptedPass = SomeClass.encrypt(new String(passwordField.getPassword());
please excuse the well off-topic post