MD5加密 32位小写

MD5加密 32位小写

MD5 加密,32 位小写
import java.security.MessageDigest;

/**
 * 功能描述: 概述:MD5-32(appKey+timestamp+appSecret),MD5 加密,32 位小写 #返回数据
 * 创  建 人: bailangtao
 */

public class MD532 {
    
    
    public static void main(String[] args) {
    
    
		String appkey = "F958B33D5E7E485C98F21C594C56203D";
		String appSecret = "EE785D969B054927AE66D680BF20EA5A";
        long timestamp = System.currentTimeMillis();
        String encryptStr = appkey + timestamp + appSecret;

        MessageDigest md5;
        try {
    
    
            md5 = MessageDigest.getInstance("MD5");
            byte[] md5Bytes = md5.digest(encryptStr.getBytes());
            StringBuffer hexValue = new StringBuffer();
            for (int i = 0; i < md5Bytes.length; i++) {
    
    
                int val = ((int) md5Bytes[i]) & 0xff;
                if (val < 16)
                    hexValue.append("0");
                hexValue.append(Integer.toHexString(val));
            }
            //默认小写,在tostring后加toUpperCase()即为大写加密
            encryptStr = hexValue.toString();
            System.out.println(encryptStr);
        } catch (Exception e) {
    
    
            throw new RuntimeException(e);
        }
    }
}

运行结果

54359beeb9577f87ebb11aa009aaa252

猜你喜欢

转载自blog.csdn.net/bai_langtao/article/details/126547389