0
我有一个问题,在jdk 1.4而不是jdk 1.6编译应用程序。字节到十六进制数字格式化符号找不到
String encryptedString = null;
byte[] bytesToBeEncrypted;
try {
// convert string to bytes using a encoding scheme
bytesToBeEncrypted = ren_pass.getBytes("UTF-8");
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] theDigest = md.digest(bytesToBeEncrypted);
// convert each byte to a hexadecimal digit
Formatter formatter = new Formatter();
for (int i = 0; i <= theDigest.length; i++) {
byte b = theDigest[i];
//for (byte b : theDigest) {
formatter.format("%02x", b); // error on this statement b cannot find symbol
}
encryptedString = formatter.toString().toLowerCase();
System.out.print(encryptedString);
} catch (UnsupportedEncodingException eq) {
eq.printStackTrace();
} catch (NoSuchAlgorithmException ew) {
ew.printStackTrace();
}
上面的代码工作正常JDK 1.6 ......但不是在JDK 1.4 ...
它显示错误符号B没有发现......
请给我一些解决方案来纠正它...