Search in sources :

Example 1 with Digester

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);
}
Also used : Digester(cn.hutool.crypto.digest.Digester) Test(org.junit.Test)

Example 2 with Digester

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);
}
Also used : Digester(cn.hutool.crypto.digest.Digester) Test(org.junit.Test)

Example 3 with Digester

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);
}
Also used : Digester(cn.hutool.crypto.digest.Digester) Test(org.junit.Test)

Example 4 with Digester

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);
}
Also used : Digester(cn.hutool.crypto.digest.Digester) Test(org.junit.Test)

Example 5 with Digester

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);
}
Also used : Digester(cn.hutool.crypto.digest.Digester) Test(org.junit.Test)

Aggregations

Digester (cn.hutool.crypto.digest.Digester)7 Test (org.junit.Test)6 UserModel (io.jpom.model.data.UserModel)1