Перенос минимума из lab2

This commit is contained in:
2026-11-05 18:00:36 +03:00
parent 0ab3a341aa
commit 4303783848
24 changed files with 3359 additions and 8 deletions
+23
View File
@@ -0,0 +1,23 @@
package password
import "testing"
func TestArgon2idRoundTrip(t *testing.T) {
p := Params{Time: 1, Memory: 8, Threads: 1}
encoded, err := p.Hash("correct-horse-1")
if err != nil {
t.Fatal(err)
}
if encoded == "correct-horse-1" || len(encoded) < 20 {
t.Fatalf("hash is not a PHC string: %s", encoded)
}
if !Verify("correct-horse-1", encoded) {
t.Fatal("matching password rejected")
}
if Verify("other-password-1", encoded) {
t.Fatal("wrong password accepted")
}
if Verify("correct-horse-1", "sha256:deadbeef") {
t.Fatal("non-argon string accepted")
}
}