Checkpoint 5

This commit is contained in:
Philipp Wellner
2023-07-30 12:38:47 +02:00
parent 9116635efc
commit 9b1eba127a
9 changed files with 177 additions and 43 deletions

21
hash/hash.go Normal file
View File

@@ -0,0 +1,21 @@
package hash
import (
"encoding/binary"
"encoding/hex"
"golang.org/x/crypto/scrypt"
)
func HashCardUid(card uint64) string {
b := make([]byte, 8)
binary.LittleEndian.PutUint64(b, card)
hashed, err := scrypt.Key(b, []byte("hkRXwLlQKmCJoy5qaahp"), 16384, 8, 1, 64)
if err != nil {
panic(err) // can only happen when scrypt params are garbage
}
hashedHex := hex.EncodeToString(hashed)
return hashedHex
}