use of cn.hutool.crypto.digest.Digester in project hutool by looly.
the class DigestTest method md5WithSaltTest.
@Test
public void md5WithSaltTest() {
String testStr = "test中文";
Digester md5 = new Digester(DigestAlgorithm.MD5);
// 加盐
md5.setSalt("saltTest".getBytes());
String md5Hex1 = md5.digestHex(testStr);
Assert.assertEquals("762f7335200299dfa09bebbb601a5bc6", md5Hex1);
String md5Hex2 = md5.digestHex(IoUtil.toUtf8Stream(testStr));
Assert.assertEquals("762f7335200299dfa09bebbb601a5bc6", md5Hex2);
// 重复2次
md5.setDigestCount(2);
String md5Hex3 = md5.digestHex(testStr);
Assert.assertEquals("2b0616296f6755d25efc07f90afe9684", md5Hex3);
String md5Hex4 = md5.digestHex(IoUtil.toUtf8Stream(testStr));
Assert.assertEquals("2b0616296f6755d25efc07f90afe9684", md5Hex4);
}
use of cn.hutool.crypto.digest.Digester in project hutool by looly.
the class DigestTest method digesterTest.
@Test
public void digesterTest() {
String testStr = "test中文";
Digester md5 = new Digester(DigestAlgorithm.MD5);
String digestHex = md5.digestHex(testStr);
Assert.assertEquals("5393554e94bf0eb6436f240a4fd71282", digestHex);
}
use of cn.hutool.crypto.digest.Digester in project hutool by dromara.
the class DigestTest method digesterTest.
@Test
public void digesterTest() {
String testStr = "test中文";
Digester md5 = new Digester(DigestAlgorithm.MD5);
String digestHex = md5.digestHex(testStr);
Assert.assertEquals("5393554e94bf0eb6436f240a4fd71282", digestHex);
}
use of cn.hutool.crypto.digest.Digester in project Jpom by dromara.
the class TestString method test1.
@Test
public void test1() {
System.out.println(SecureUtil.sha256("1"));
System.out.println(SecureUtil.sha256("admin"));
int randomInt = 2;
RandomUtil.randomInt(1, 100);
System.out.println(randomInt);
String nowStr = "admin";
nowStr = new Digester(DigestAlgorithm.SHA256).setDigestCount(2).digestHex(nowStr);
System.out.println(nowStr);
}
use of cn.hutool.crypto.digest.Digester in project hutool by looly.
the class DigestTest method digesterTest.
@Test
public void digesterTest() {
String testStr = "test中文";
Digester md5 = new Digester(DigestAlgorithm.MD5);
String digestHex = md5.digestHex(testStr);
Assert.assertEquals("5393554e94bf0eb6436f240a4fd71282", digestHex);
}