Checkpoint 5
This commit is contained in:
21
hash/hash.go
Normal file
21
hash/hash.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user