1
1
Fork 0
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:
Zack Scholl 2021-04-21 17:18:50 -07:00
parent 3359e7996f
commit f58a5788b2

View file

@ -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.