summaryrefslogtreecommitdiff
path: root/tests/functional/hash-and-check/scrypt.go
blob: 9eeeb2228e3a939d263c3809887a3a29260e325f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package scrypt

import (
	g "gobang"

)



func MainTest() {
	g.Testing("from a known input we check the hash", func() {
		var (
			password = []byte("a fixed password")
			salt     = []byte("a fixed salt____________________")
		)

		hashInput := HashInputT{
			Password: password,
			Salt:     salt,
		}
		hash, err := Hash(hashInput)
		g.TErrorIf(err)

		checkInput := CheckInputT{
			Password: password,
			Salt:     salt,
			Hash:     hash,
		}
		ok, err := Check(checkInput)
		g.TErrorIf(err)
		g.TAssertEqual(ok, true)
	})

	g.Testing("we can genereate a hash and check it is equal", func() {
		password, err := Salt()
		g.TErrorIf(err)

		salt, err := Salt()
		g.TErrorIf(err)

		hashInput := HashInputT{
			Password: password,
			Salt:     salt,
		}
		hash, err := Hash(hashInput)
		g.TErrorIf(err)

		checkInput := CheckInputT{
			Password: password,
			Salt:     salt,
			Hash:     hash,
		}
		ok, err := Check(checkInput)
		g.TErrorIf(err)

		g.TAssertEqual(ok, true)
	})
}