From b93acdcaeff1482030c4fa0ef76009a7fc9a230e Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sat, 3 May 2025 17:17:14 -0400 Subject: [PATCH] Improved decryption error messages --- wrappers/chacha.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wrappers/chacha.go b/wrappers/chacha.go index 653d1bd..101049a 100644 --- a/wrappers/chacha.go +++ b/wrappers/chacha.go @@ -2,8 +2,8 @@ package wrappers import ( "crypto/rand" + "fmt" "io" - "log" "golang.org/x/crypto/chacha20poly1305" ) @@ -45,7 +45,7 @@ func EncryptCha(data []byte, passphrase []byte) []byte { // DecryptCha decrypts data using ChaCha20-Poly1305 func DecryptCha(encryptedData []byte, passphrase []byte) []byte { if len(encryptedData) < saltSizeCha+nonceSizeCha { - log.Fatalf("encrypted data is too short") + fmt.Println("Encrypted data is too short") return nil } @@ -63,7 +63,7 @@ func DecryptCha(encryptedData []byte, passphrase []byte) []byte { // decrypt the data plaintext, err := aead.Open(nil, nonce, ciphertext, nil) if err != nil { - log.Fatalf("decryption failed (possibly wrong passphrase): %w", err) + fmt.Printf("Decryption failed (possibly wrong passphrase): %s", err.Error()) return nil }