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