算法分类
典型的散列算法包括 MD2、MD4、MD5 和 SHA-1
待更新...
代码
/**
* md5散列算法测试
*/
@Test
public void testMD5(){
String pwd = "111111";
String salt = "qwerty";
/**
* Md5Hash(Object source, Object salt, int hashIterations)
* source:明文,原始密码
* salt:盐,通过使用随机数
* hashIterations:散列次数
*/
Md5Hash md5Hash = new Md5Hash(pwd, salt, 2);
String md5Pwd = md5Hash.toString();
System.out.println(md5Pwd);
/**
* SimpleHash(String algorithmName, Object source, Object salt, int hashIterations)
* algorithmName:算法名称
* source:明文,原始密码
* salt:盐
* hashIterations:散列次数
*/
SimpleHash simpleHash = new SimpleHash("md5", pwd, salt, 2);
System.out.println(simpleHash);
}
测试结果
36f2dfa24d0a9fa97276abbe13e596fc
36f2dfa24d0a9fa97276abbe13e596fc