diff --git a/models/key.go b/models/key.go index 475b729..50be628 100644 --- a/models/key.go +++ b/models/key.go @@ -46,14 +46,17 @@ func storeKeyHash(plaintext string, filePath string) error { func compareHashWithPlaintext(plaintext string, filePath string) (bool, error) { hashBytes, err := os.ReadFile(filePath) if err != nil { + log.Printf("compareHashWithPlaintext error reading hashfile : '%s'\n", err) return false, err } err = bcrypt.CompareHashAndPassword(hashBytes, []byte(plaintext)) if err != nil { if err == bcrypt.ErrMismatchedHashAndPassword { + log.Printf("compareHashWithPlaintext provided key is incorrect") return false, nil // Passwords don't match } + log.Printf("compareHashWithPlaintext error comparing provided key : '%s'\n", err) return false, err // Other error occurred } @@ -71,6 +74,7 @@ func ReceiveKey(key string) error { filePath, _ := getHashFilePath() if filePath != "" { + log.Printf("ReceiveKey detected hash file at '%s'\n", filePath) // File already exists, compare received key with hash in file compare, err := compareHashWithPlaintext(key, filePath) if err != nil {