From e37c1fc7fe6b211c05f9124653c9b338e587ca8a Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 19 Oct 2024 09:07:14 -0300 Subject: src/scrypt.go: Create HashInput and CheckInput for named arguments --- tests/functional/hash-and-check/scrypt.go | 32 ++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'tests/functional/hash-and-check') diff --git a/tests/functional/hash-and-check/scrypt.go b/tests/functional/hash-and-check/scrypt.go index 17f2982..065b9b5 100644 --- a/tests/functional/hash-and-check/scrypt.go +++ b/tests/functional/hash-and-check/scrypt.go @@ -9,15 +9,24 @@ import ( func MainTest() { g.Testing("from a known input we check the hash", func() { - const ( - password = "a fixed password" - salt = "a fixed salt____________________" + var ( + password = []byte("a fixed password") + salt = []byte("a fixed salt____________________") ) - hash, err := Hash([]byte(password), []byte(salt)) + hashInput := HashInput{ + Password: password, + Salt: salt, + } + hash, err := Hash(hashInput) g.TErrorIf(err) - ok, err := Check([]byte(password), []byte(salt), hash) + checkInput := CheckInput{ + Password: password, + Salt: salt, + Hash: hash, + } + ok, err := Check(checkInput) g.TErrorIf(err) g.TAssertEqual(ok, true) }) @@ -29,10 +38,19 @@ func MainTest() { salt, err := Salt() g.TErrorIf(err) - hash, err := Hash(password, salt) + hashInput := HashInput{ + Password: password, + Salt: salt, + } + hash, err := Hash(hashInput) g.TErrorIf(err) - ok, err := Check(password, salt, hash) + checkInput := CheckInput{ + Password: password, + Salt: salt, + Hash: hash, + } + ok, err := Check(checkInput) g.TErrorIf(err) g.TAssertEqual(ok, true) -- cgit v1.2.3