mirror of
https://github.com/schollz/croc.git
synced 2025-10-10 21:01:02 +02:00
return error not panic
This commit is contained in:
parent
3359e7996f
commit
f58a5788b2
1 changed files with 2 additions and 2 deletions
|
@ -99,8 +99,8 @@ func NewArgon2(passphrase []byte, usersalt []byte) (aead cipher.AEAD, salt []byt
|
|||
// https://pkg.go.dev/golang.org/x/crypto/chacha20poly1305
|
||||
func EncryptChaCha(plaintext []byte, aead cipher.AEAD) (encrypted []byte, err error) {
|
||||
nonce := make([]byte, aead.NonceSize(), aead.NonceSize()+len(plaintext)+aead.Overhead())
|
||||
if _, err := rand.Read(nonce); err != nil {
|
||||
panic(err)
|
||||
if _, err = rand.Read(nonce); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Encrypt the message and append the ciphertext to the nonce.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue