Ciao a tutti, sto provando a fare l'encoding di una stringa in un algoritmo MD5 e di salvarla successivamente nel database.
Qualcosa però non mi torna nel risultato:
19:57:29,052 DEBUG [Encryptor] [byteToString] the String: �Ǘ����Ϗ�Y
il mio codice:
public static byte[] encrypt(String data, String algorithm)
throws NoSuchAlgorithmException {
return encryptor(data.getBytes(),algorithm);
}


private static byte[] encryptor(byte[] obj, String algorithm)
throws NoSuchAlgorithmException {
MessageDigest msgd = MessageDigest.getInstance(algorithm);
msgd.reset();
msgd.update(obj);
return msgd.digest();

}

public static String byteToString(byte[] arr){
String s = null;
try {
s = new String( arr, "UTF-8" );
} catch (UnsupportedEncodingException ex) {
logger.debug("[byteToString] ",ex);
}
s.replaceAll( " ", "" );
logger.debug("[byteToString] the String: "+s);
return s;
}