在BlackBerry应用程序中,我使用此代码从密码中获取哈希:
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);
在这个代码块的末尾,tempSHA256Password
将会是这样的:ëÇ#ÎiGê8óq =ßÝ÷<rê¨_FR»ã
......所以绝不是我所期待的。我期待一个看起来像这样的字符串:ebc723ce6947ea38f371a03d0cdfddf73c840f7215eaa85f031446529bbb16e3
我究竟做错了什么?