22 lines
418 B
Go
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
|
|
}
|