MCPcopy
hub / github.com/gtank/cryptopasta / TestPasswordHashing

Function TestPasswordHashing

hash_test.go:24–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestPasswordHashing(t *testing.T) {
25 bcryptTests := []struct {
26 plaintext []byte
27 hash []byte
28 }{
29 {
30 plaintext: []byte("password"),
31 hash: []byte("$2a$14$uALAQb/Lwl59oHVbuUa5m.xEFmQBc9ME/IiSgJK/VHtNJJXASCDoS"),
32 },
33 }
34
35 for _, tt := range bcryptTests {
36 hashed, err := HashPassword(tt.plaintext)
37 if err != nil {
38 t.Error(err)
39 }
40
41 if err = CheckPasswordHash(hashed, tt.plaintext); err != nil {
42 t.Error(err)
43 }
44 }
45}
46
47// Benchmarks SHA256 on 16K of random data.
48func BenchmarkSHA256(b *testing.B) {

Callers

nothing calls this directly

Calls 2

HashPasswordFunction · 0.85
CheckPasswordHashFunction · 0.85

Tested by

no test coverage detected