增加Argon2类,实现Argon2算法(issue#3890@Github)

This commit is contained in:
Looly
2025-04-11 10:45:14 +08:00
parent 79485aca23
commit 1011c5ec60
2 changed files with 190 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package org.dromara.hutool.crypto.digest;
import org.dromara.hutool.core.codec.binary.Base64;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class Argon2Test {
@Test
public void argon2Test() {
final Argon2 argon2 = new Argon2();
final byte[] digest = argon2.digest("123456".toCharArray());
Assertions.assertEquals("wVGMOdzf5EdKGANPeHjaUnaFEJA0BnAq6HcF2psFmFo=", Base64.encode(digest));
}
@Test
public void argon2WithSaltTest() {
final Argon2 argon2 = new Argon2();
argon2.setSalt("123456".getBytes());
final byte[] digest = argon2.digest("123456".toCharArray());
Assertions.assertEquals("sEpbXTdMWra36JXPVxrZMm3xyoR5GkMlLhtW0Kwp9Ag=", Base64.encode(digest));
}
}