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_new.go | |
| parent | 050db499d18c61d90a68096027ac0d5aaa842f57 (diff) | |
confirm passphrase when creating
Diffstat (limited to 'internal/crud/handler_new.go')
| -rw-r--r-- | internal/crud/handler_new.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/internal/crud/handler_new.go b/internal/crud/handler_new.go index b40eec5..df0aa6e 100644 --- a/internal/crud/handler_new.go +++ b/internal/crud/handler_new.go @@ -9,11 +9,25 @@ import ( ) func NewNote(noteName, output string) error { - 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) } + utils.TryMlock(password) + defer clear(password) + + fmt.Printf("Confirm the passphrase: ") + passwordConfirm, err := utils.TakeSecureUserInput() + if err != nil { + return fmt.Errorf("failed to read passphrase: %v", err) + } + utils.TryMlock(passwordConfirm) + defer clear(passwordConfirm) + + if string(password) != string(passwordConfirm) { + return fmt.Errorf("passphrases do not match") + } encrypted, err := crypt.EncryptRawBytes([]byte(noteName), password) if err != nil { |