android MD5加密

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
public class Demo {
 
    /**
     * @param args
     * @throws NoSuchAlgorithmException
     */
    public static void main(String[] args) throws NoSuchAlgorithmException {
        MessageDigest digest = MessageDigest.getInstance("md5");
        String password = "123456";
        byte [] bytes =  digest.digest(password.getBytes());
        StringBuffer buffer = new StringBuffer();
        for(byte b: bytes){
            int number = b & 0xff;//加盐
            String hex = Integer.toHexString(number);
            if(hex.length()==1){
                buffer.append("0");
            }
            buffer.append(hex);
        }
        //md5加密后的值
        System.out.println(buffer);
 
    }
 
}
上一篇:处理:Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY error: Failed dependencies:


下一篇:CYQ.Data 轻量数据层之路 使用篇二曲 MAction 数据查询(十三)