godoor/hash/hash.go
Philipp Wellner 9b1eba127a
Checkpoint 5
2023-07-30 12:38:47 +02:00

22 lines
418 B
Go

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
}