aboutsummaryrefslogtreecommitdiff
path: root/internal/crud/handler_new.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/crud/handler_new.go')
-rw-r--r--internal/crud/handler_new.go16
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 {