Jsp 未找到字节到十六进制数字格式化程序符号

Jsp 未找到字节到十六进制数字格式化程序符号,jsp,servlets,md5,jdk1.4,Jsp,Servlets,Md5,Jdk1.4,我在用JDK1.4而不是JDK1.6编译应用程序时遇到了一个问题 String encryptedString = null; byte[] bytesToBeEncrypted; try { // convert string to bytes using a encoding scheme bytesToBeEncrypted = ren_pass.getBytes("

我在用JDK1.4而不是JDK1.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();
            }
String encryptedString=null;
字节[]bytesToBeEncrypted;
试一试{
//使用编码方案将字符串转换为字节
bytesToBeEncrypted=ren_pass.getBytes(“UTF-8”);
MessageDigest md=MessageDigest.getInstance(“MD5”);
字节[]theDigest=md.digest(bytesToBeEncrypted);
//将每个字节转换为十六进制数字
格式化程序格式化程序=新格式化程序();

对于(inti=0;ijdk1.4没有java.util.Formatter,您是否使用java.util.logging.Formatter编译代码

请改用Character.forDigit(字节值,16)