diff options
| author | ishaan <contact@ishaan.cc> | 2026-07-12 16:41:00 +0530 |
|---|---|---|
| committer | ishaan <contact@ishaan.cc> | 2026-07-12 16:41:00 +0530 |
| commit | 050db499d18c61d90a68096027ac0d5aaa842f57 (patch) | |
| tree | 2d0cd6db07407c2d44c8ea7ec899fb3088766d01 /internal/crud/handler_new.go | |
| parent | 7b5328536a82755c2724f2075c31035d709588df (diff) | |
add init/new/edit subcommands, config, mlock/cleared sensitive info
Diffstat (limited to 'internal/crud/handler_new.go')
| -rw-r--r-- | internal/crud/handler_new.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/crud/handler_new.go b/internal/crud/handler_new.go new file mode 100644 index 0000000..b40eec5 --- /dev/null +++ b/internal/crud/handler_new.go @@ -0,0 +1,36 @@ +package crud + +import ( + "fmt" + "os" + + "gitlab.com/whiteboardguy/eno/internal/crypt" + "gitlab.com/whiteboardguy/eno/internal/utils" +) + +func NewNote(noteName, output string) error { + fmt.Printf("Enter the super secure passphrase: ") + password, err := utils.TakeSecureUserInput() + if err != nil { + return fmt.Errorf("failed to read passphrase: %v", err) + } + + encrypted, err := crypt.EncryptRawBytes([]byte(noteName), password) + if err != nil { + return err + } + + fmt.Println(output) + file, err := os.Create(output) + if err != nil { + return err + } + + _, err = file.Write(encrypted) + if err != nil { + return err + } + + file.Sync() + return nil +} |