【发布时间】:2012-04-11 21:20:02
【问题描述】:
在 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
我做错了什么?
【问题讨论】:
标签: java blackberry sha256