MD5 encryption twice lost the first letter

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/u014064071/article/details/102755250

This method, MD5 encrypted twice after missing the first letter, the second method can be used normally

--- lost the first letter

public static String md5Encrypt(String input) {
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("MD5");
            byte buffer[] = input.getBytes();
            md.update(buffer);
            byte bDigest[] = md.digest();
            md.reset();
            BigInteger bi = new BigInteger(1, bDigest);
//            System.out.println(bi.toString(16));
            return bi.toString(16);
        } catch (Exception e) {

        }
        return null;
    }

 

 

-----Can be used normally

      public static String Md5(String str) {
            try {
                MessageDigest md5 = MessageDigest.getInstance("MD5");
                byte[] bs = md5.digest(str.getBytes());
                return new String(new Hex().encode(bs));
            } catch (Exception e) {
            }
            return null;
        }

Guess you like

Origin blog.csdn.net/u014064071/article/details/102755250