diff options
| author | ishaan <contact@ishaan.cc> | 2026-07-12 08:11:50 +0530 |
|---|---|---|
| committer | ishaan <contact@ishaan.cc> | 2026-07-12 08:11:50 +0530 |
| commit | 777497ec7972d60621dc2ec42495aa73c77dfa41 (patch) | |
| tree | b11e147f1feb35d612a84a2d624899c1b42ab23c /internal/crud/raw_Encrypt.go | |
| parent | e9f777d8f7b8b77993f0b88032c33bbef06959c0 (diff) | |
go the go
Diffstat (limited to 'internal/crud/raw_Encrypt.go')
| -rw-r--r-- | internal/crud/raw_Encrypt.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/internal/crud/raw_Encrypt.go b/internal/crud/raw_Encrypt.go index ec2b4f6..38c2e07 100644 --- a/internal/crud/raw_Encrypt.go +++ b/internal/crud/raw_Encrypt.go @@ -2,6 +2,7 @@ package crud import ( "fmt" + "log/slog" "os" "gitlab.com/whiteboardguy/eno/internal/utils" @@ -16,31 +17,31 @@ func RawEncryptFile(inputFile, outputFile string) { fmt.Scanln(&overwriteConfirm) if overwriteConfirm != "y" && overwriteConfirm != "Y" { - fmt.Fprintln(os.Stderr, "write aborted") + slog.Error("write aborted") os.Exit(1) } } fileBytes, err := os.ReadFile(inputFile) if err != nil { - fmt.Fprintln(os.Stderr, err.Error()) + slog.Error("failed to read input file", "error", err) os.Exit(1) } fmt.Printf("Enter a super secure passphrase: ") password, err := utils.TakeSecureUserInput() if err != nil { - fmt.Fprintln(os.Stderr, err.Error()) + slog.Error("failed to read passphrase", "error", err) os.Exit(1) } headers := NewFileHeaders() - fmt.Println(headers) + slog.Debug("file headers", "headers", headers) key := argon2.IDKey(password, headers.Salt[:], 1, 2*1024*1024, 2, 32) aead, err := chacha20poly1305.New(key) if err != nil { - fmt.Fprintln(os.Stderr, err.Error()) + slog.Error("failed to create cipher", "error", err) os.Exit(1) } @@ -54,7 +55,7 @@ func RawEncryptFile(inputFile, outputFile string) { target = append(target, encrypted...) if err := os.WriteFile(outputFile, target, 0644); err != nil { - fmt.Fprintln(os.Stderr, err.Error()) + slog.Error("failed to write output file", "error", err) os.Exit(1) } } |