This commit is contained in:
@@ -29,11 +29,13 @@ func getHashFilePath() (string, error) {
|
|||||||
func storeKeyHash(plaintext string, filePath string) error {
|
func storeKeyHash(plaintext string, filePath string) error {
|
||||||
hash, err := bcrypt.GenerateFromPassword([]byte(plaintext), bcrypt.DefaultCost)
|
hash, err := bcrypt.GenerateFromPassword([]byte(plaintext), bcrypt.DefaultCost)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Printf("storeKeyHash error generating hash : '%s'\n", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.WriteFile(filePath, hash, 0600)
|
err = os.WriteFile(filePath, hash, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Printf("storeKeyHash error writing file : '%s'\n", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,6 +80,7 @@ func ReceiveKey(key string) error {
|
|||||||
return errors.New("secret key is not correct")
|
return errors.New("secret key is not correct")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
log.Printf("ReceiveKey storing key into file '%s'\n", filePath)
|
||||||
storeKeyHash(key, filePath)
|
storeKeyHash(key, filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user