aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/eno/cobra.go2
-rwxr-xr-xenobin4994131 -> 5335157 bytes
-rw-r--r--internal/crud/handler_edit.go3
-rw-r--r--internal/crud/handler_new.go11
-rw-r--r--internal/utils/cli.go4
-rw-r--r--internal/utils/utils.go25
6 files changed, 42 insertions, 3 deletions
diff --git a/cmd/eno/cobra.go b/cmd/eno/cobra.go
index de383d6..b988dab 100644
--- a/cmd/eno/cobra.go
+++ b/cmd/eno/cobra.go
@@ -177,7 +177,7 @@ var newCmd = &cobra.Command{
}
}
- err = crud.NewNote(noteName, output)
+ err = crud.NewNote(output)
if err != nil {
cmd.PrintErrln("Error:", err)
os.Exit(1)
diff --git a/eno b/eno
index 7146e82..0e800b5 100755
--- a/eno
+++ b/eno
Binary files differ
diff --git a/internal/crud/handler_edit.go b/internal/crud/handler_edit.go
index f7bbe34..0e13be3 100644
--- a/internal/crud/handler_edit.go
+++ b/internal/crud/handler_edit.go
@@ -56,6 +56,9 @@ func EditNote(notePath, editorString string) error {
err = os.WriteFile(notePath, encrypted, noteInfo.Mode().Perm())
+ // utils.ClearTerm()
+ fmt.Println("Saved:", noteInfo.Name())
+
return err
}
diff --git a/internal/crud/handler_new.go b/internal/crud/handler_new.go
index df0aa6e..f949969 100644
--- a/internal/crud/handler_new.go
+++ b/internal/crud/handler_new.go
@@ -8,7 +8,7 @@ import (
"gitlab.com/whiteboardguy/eno/internal/utils"
)
-func NewNote(noteName, output string) error {
+func NewNote(output string) error {
fmt.Printf("Enter the passphrase: ")
password, err := utils.TakeSecureUserInput()
if err != nil {
@@ -29,7 +29,10 @@ func NewNote(noteName, output string) error {
return fmt.Errorf("passphrases do not match")
}
- encrypted, err := crypt.EncryptRawBytes([]byte(noteName), password)
+ encrypted, err := crypt.EncryptRawBytes(
+ []byte(string(utils.RandomLettersNumbers(37))+"\nYou can Delete all of this ^^^"),
+ password,
+ )
if err != nil {
return err
}
@@ -46,5 +49,9 @@ func NewNote(noteName, output string) error {
}
file.Sync()
+
+ // utils.ClearTerm()
+ fmt.Println("New note saved at:", file.Name())
+
return nil
}
diff --git a/internal/utils/cli.go b/internal/utils/cli.go
index 773b529..46eef78 100644
--- a/internal/utils/cli.go
+++ b/internal/utils/cli.go
@@ -32,3 +32,7 @@ func AskUserYesNo(prompt string, defaultVal bool) (bool, error) {
return false, nil
}
}
+
+func ClearTerm() {
+ fmt.Print("\033[H\033[2J")
+}
diff --git a/internal/utils/utils.go b/internal/utils/utils.go
index be3f3ad..96ca0f0 100644
--- a/internal/utils/utils.go
+++ b/internal/utils/utils.go
@@ -1,6 +1,7 @@
package utils
import (
+ "crypto/rand"
"fmt"
"os"
"os/signal"
@@ -47,3 +48,27 @@ func TakeSecureUserInput() ([]byte, error) {
return sensInfo, nil
}
+
+func RandomLetters(n int) []byte {
+ const alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ b := make([]byte, n)
+ if _, err := rand.Read(b); err != nil {
+ return nil
+ }
+ for i := range b {
+ b[i] = alphabet[int(b[i])%len(alphabet)]
+ }
+ return b
+}
+
+func RandomLettersNumbers(n int) []byte {
+ const alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
+ b := make([]byte, n)
+ if _, err := rand.Read(b); err != nil {
+ return nil
+ }
+ for i := range b {
+ b[i] = alphabet[int(b[i])%len(alphabet)]
+ }
+ return b
+}