diff options
| author | ishaan <contact@ishaan.cc> | 2026-07-13 05:41:14 +0530 |
|---|---|---|
| committer | ishaan <contact@ishaan.cc> | 2026-07-13 05:41:14 +0530 |
| commit | 6fa6f58e43a13747388973fe0ec7018a2f0683df (patch) | |
| tree | 030a6fe9c21a30a1affad2fefa192caf807dfc79 /internal/crud/handler_edit.go | |
| parent | 050db499d18c61d90a68096027ac0d5aaa842f57 (diff) | |
confirm passphrase when creating
Diffstat (limited to 'internal/crud/handler_edit.go')
| -rw-r--r-- | internal/crud/handler_edit.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/internal/crud/handler_edit.go b/internal/crud/handler_edit.go index 6c31324..f7bbe34 100644 --- a/internal/crud/handler_edit.go +++ b/internal/crud/handler_edit.go @@ -15,7 +15,7 @@ func EditNote(notePath, editorString string) error { return err } - fmt.Printf("Enter the super secure passphrase: ") + fmt.Printf("Enter the passphrase: ") password, err := utils.TakeSecureUserInput() if err != nil { return fmt.Errorf("failed to read passphrase: %v", err) @@ -32,6 +32,7 @@ func EditNote(notePath, editorString string) error { plaintext, err := crypt.DecryptRawBytes(ciphertext, password) if err != nil { return err } utils.TryMlock(plaintext) + defer clear(plaintext) defer deferredCleanTmpFile(tmpFile, len(plaintext)) defer os.Remove(tmpFile.Name()) @@ -46,13 +47,12 @@ func EditNote(notePath, editorString string) error { newContent, err := os.ReadFile(tmpFile.Name()) if err != nil { return err } utils.TryMlock(newContent) + defer clear(newContent) os.WriteFile(tmpFile.Name(), make([]byte, len(newContent)), 0600) encrypted, err := crypt.EncryptRawBytes(newContent, password) if err != nil { return err } - clear(newContent) - clear(plaintext) err = os.WriteFile(notePath, encrypted, noteInfo.Mode().Perm()) |