godoor/hash/hash.go

22 lines
418 B
Go
Raw Permalink Normal View History

2023-07-30 10:38:47 +00:00
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
}