Works sorta

This commit is contained in:
Arti Zirk
2022-04-03 20:34:46 +03:00
parent 092e44cfa5
commit 846a610c58
4 changed files with 80 additions and 5 deletions

View File

@@ -1,7 +1,10 @@
package main
import (
"encoding/binary"
"encoding/hex"
"fmt"
"golang.org/x/crypto/scrypt"
"time"
)
@@ -36,7 +39,7 @@ func printCardId(card uint64) {
fmt.Printf("\n")
}
func (w *Wiegand) cardRunner() {
func (w *Wiegand) cardRunner(validUids ValidUids) {
for {
// Wait for bit timeout
fmt.Printf("Waiting for bit timeout\n")
@@ -56,6 +59,24 @@ func (w *Wiegand) cardRunner() {
printCardId(card)
b := make([]byte, 8)
binary.LittleEndian.PutUint64(b, card)
hashed, err := scrypt.Key(b, []byte("hashsah"), 16384, 8, 1, 64)
if err != nil {
panic(err)
}
hashedHex := hex.EncodeToString(hashed)
fmt.Println(hashedHex)
_, ok := validUids[hashedHex]
if ok {
fmt.Println("Opening door")
w.OpenDoor()
} else {
fmt.Println("Unknown card")
}
w.bitNr = 0
}
}