blob: b40eec592fd0d401ef5daaf59908436cda78602e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
}
|