本文整理匯總了Java中de.mkammerer.argon2.Argon2.hash方法的典型用法代碼示例。如果您正苦於以下問題:Java Argon2.hash方法的具體用法?Java Argon2.hash怎麽用?Java Argon2.hash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類de.mkammerer.argon2.Argon2
的用法示例。
在下文中一共展示了Argon2.hash方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testArgon2i
import de.mkammerer.argon2.Argon2; //導入方法依賴的package包/類
@Test
public void testArgon2i() throws Exception {
Argon2 sut = Argon2Factory.create(Argon2Factory.Argon2Types.ARGON2i);
String hash = sut.hash(2, 65536, 1, "password");
System.out.println(hash);
assertThat(hash.startsWith("$argon2i$"), is(true));
assertThat(sut.verify(hash, "password"), is(true));
assertThat(sut.verify(hash, "not-the-password"), is(false));
}
示例2: testArgon2iWithChars
import de.mkammerer.argon2.Argon2; //導入方法依賴的package包/類
@Test
public void testArgon2iWithChars() throws Exception {
Argon2 sut = Argon2Factory.create(Argon2Factory.Argon2Types.ARGON2i);
String hash = sut.hash(2, 65536, 1, "password".toCharArray());
System.out.println(hash);
assertThat(hash.startsWith("$argon2i$"), is(true));
assertThat(sut.verify(hash, "password".toCharArray()), is(true));
assertThat(sut.verify(hash, "not-the-password".toCharArray()), is(false));
}
示例3: testCharsAreLeftIntact
import de.mkammerer.argon2.Argon2; //導入方法依賴的package包/類
@Test
public void testCharsAreLeftIntact() throws Exception {
Argon2 sut = Argon2Factory.create(Argon2Factory.Argon2Types.ARGON2i);
char[] chars = "password".toCharArray();
sut.hash(2, 65536, 1, chars);
assertThat(chars, equalTo("password".toCharArray()));
}
示例4: testArgon2d
import de.mkammerer.argon2.Argon2; //導入方法依賴的package包/類
@Test
public void testArgon2d() throws Exception {
Argon2 sut = Argon2Factory.create(Argon2Factory.Argon2Types.ARGON2d);
String hash = sut.hash(2, 65536, 1, "password");
System.out.println(hash);
assertThat(hash.startsWith("$argon2d$"), is(true));
assertThat(sut.verify(hash, "password"), is(true));
assertThat(sut.verify(hash, "not-the-password"), is(false));
}
示例5: testArgon2dWithChars
import de.mkammerer.argon2.Argon2; //導入方法依賴的package包/類
@Test
public void testArgon2dWithChars() throws Exception {
Argon2 sut = Argon2Factory.create(Argon2Factory.Argon2Types.ARGON2d);
String hash = sut.hash(2, 65536, 1, "password".toCharArray());
System.out.println(hash);
assertThat(hash.startsWith("$argon2d$"), is(true));
assertThat(sut.verify(hash, "password".toCharArray()), is(true));
assertThat(sut.verify(hash, "not-the-password".toCharArray()), is(false));
}
示例6: testArgon2id
import de.mkammerer.argon2.Argon2; //導入方法依賴的package包/類
@Test
public void testArgon2id() throws Exception {
Argon2 sut = Argon2Factory.create(Argon2Factory.Argon2Types.ARGON2id);
String hash = sut.hash(2, 65536, 1, "password");
System.out.println(hash);
assertThat(hash.startsWith("$argon2id$"), is(true));
assertThat(sut.verify(hash, "password"), is(true));
assertThat(sut.verify(hash, "not-the-password"), is(false));
}
示例7: testArgon2idWithChars
import de.mkammerer.argon2.Argon2; //導入方法依賴的package包/類
@Test
public void testArgon2idWithChars() throws Exception {
Argon2 sut = Argon2Factory.create(Argon2Factory.Argon2Types.ARGON2id);
String hash = sut.hash(2, 65536, 1, "password".toCharArray());
System.out.println(hash);
assertThat(hash.startsWith("$argon2id$"), is(true));
assertThat(sut.verify(hash, "password".toCharArray()), is(true));
assertThat(sut.verify(hash, "not-the-password".toCharArray()), is(false));
}
示例8: testArgon2iWithArgs
import de.mkammerer.argon2.Argon2; //導入方法依賴的package包/類
@Test
public void testArgon2iWithArgs() throws Exception {
Argon2 sut = Argon2Factory.create(32, 64);
String hash = sut.hash(2, 65536, 1, "password");
System.out.println(hash);
assertThat(hash.startsWith("$argon2i$"), is(true));
assertThat(sut.verify(hash, "password"), is(true));
assertThat(sut.verify(hash, "not-the-password"), is(false));
}
示例9: testArgon2dWithArgs
import de.mkammerer.argon2.Argon2; //導入方法依賴的package包/類
@Test
public void testArgon2dWithArgs() throws Exception {
Argon2 sut = Argon2Factory.create(Argon2Factory.Argon2Types.ARGON2d, 32, 64);
String hash = sut.hash(2, 65536, 1, "password");
System.out.println(hash);
assertThat(hash.startsWith("$argon2d$"), is(true));
assertThat(sut.verify(hash, "password"), is(true));
assertThat(sut.verify(hash, "not-the-password"), is(false));
}
示例10: testArgon2idWithArgs
import de.mkammerer.argon2.Argon2; //導入方法依賴的package包/類
@Test
public void testArgon2idWithArgs() throws Exception {
Argon2 sut = Argon2Factory.create(Argon2Factory.Argon2Types.ARGON2id, 32, 64);
String hash = sut.hash(2, 65536, 1, "password");
System.out.println(hash);
assertThat(hash.startsWith("$argon2id$"), is(true));
assertThat(sut.verify(hash, "password"), is(true));
assertThat(sut.verify(hash, "not-the-password"), is(false));
}
示例11: testUTF8
import de.mkammerer.argon2.Argon2; //導入方法依賴的package包/類
@Test
public void testUTF8() throws Exception {
String password = "ŧҺìş ίŝ ứţƒ-8";
Argon2 sut = Argon2Factory.create();
String hash = sut.hash(2, 65535, 1, password, Charset.forName("UTF-8"));
assertThat(sut.verify(hash, password, Charset.forName("UTF-8")), is(true));
}
示例12: testInvalidParameters
import de.mkammerer.argon2.Argon2; //導入方法依賴的package包/類
@Test(expected = IllegalStateException.class)
public void testInvalidParameters() throws Exception {
Argon2 sut = Argon2Factory.create();
sut.hash(0, 0, 0, "password");
}