summaryrefslogtreecommitdiff
path: root/tests/functional/hash-and-check/scrypt.go
blob: 17f29826e592f86900ab1574fe0316ee18eeb464 (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
package scrypt

import (
	g "gobang"

)



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

		hash, err := Hash([]byte(password), []byte(salt))
		g.TErrorIf(err)

		ok, err := Check([]byte(password), []byte(salt), hash)
		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)

		hash, err := Hash(password, salt)
		g.TErrorIf(err)

		ok, err := Check(password, salt, hash)
		g.TErrorIf(err)

		g.TAssertEqual(ok, true)
	})
}