mirror of
https://github.com/Awuqing/BackupX.git
synced 2026-09-04 23:16:41 +08:00
first commit
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package security
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestHashAndComparePassword(t *testing.T) {
|
||||
hash, err := HashPassword("super-secret-password")
|
||||
if err != nil {
|
||||
t.Fatalf("HashPassword returned error: %v", err)
|
||||
}
|
||||
if hash == "super-secret-password" {
|
||||
t.Fatalf("expected hashed password to differ from plain text")
|
||||
}
|
||||
if err := ComparePassword(hash, "super-secret-password"); err != nil {
|
||||
t.Fatalf("ComparePassword returned error: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user