In a BlackBerry application, I am using this code in order to get a hash from a password:
SHA256Digest sha256d = new SHA256Digest();
byte[] passwordData = null;
try {
passwordData = password.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
DigestOutputStream outputStream = new DigestOutputStream(sha256d, null);
try {
outputStream.write(passwordData);
} catch (IOException e) {
e.printStackTrace();
}
byte[] hashedValue = sha256d.getDigest();
tempSHA256Password = new String(hashedValue);
System.out.println(tempSHA256Password);
At the end of this code block, the tempSHA256Password
is going to be something that looks like this: ëÇ#ÎiGê8óq =ßÝ÷<rê¨_FR»ã
... so in no way what I am expecting. I am expecting a string that looks like this: ebc723ce6947ea38f371a03d0cdfddf73c840f7215eaa85f031446529bbb16e3
What am I doing wrong?