mirror of
https://github.com/rwinkhart/rcw.git
synced 2026-08-27 20:36:30 -04:00
Improved decryption error messages
This commit is contained in:
+3
-3
@@ -2,8 +2,8 @@ package wrappers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
|
|
||||||
"golang.org/x/crypto/chacha20poly1305"
|
"golang.org/x/crypto/chacha20poly1305"
|
||||||
)
|
)
|
||||||
@@ -45,7 +45,7 @@ func EncryptCha(data []byte, passphrase []byte) []byte {
|
|||||||
// DecryptCha decrypts data using ChaCha20-Poly1305
|
// DecryptCha decrypts data using ChaCha20-Poly1305
|
||||||
func DecryptCha(encryptedData []byte, passphrase []byte) []byte {
|
func DecryptCha(encryptedData []byte, passphrase []byte) []byte {
|
||||||
if len(encryptedData) < saltSizeCha+nonceSizeCha {
|
if len(encryptedData) < saltSizeCha+nonceSizeCha {
|
||||||
log.Fatalf("encrypted data is too short")
|
fmt.Println("Encrypted data is too short")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ func DecryptCha(encryptedData []byte, passphrase []byte) []byte {
|
|||||||
// decrypt the data
|
// decrypt the data
|
||||||
plaintext, err := aead.Open(nil, nonce, ciphertext, nil)
|
plaintext, err := aead.Open(nil, nonce, ciphertext, nil)
|
||||||
if err != 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user