1
1
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 05:11:06 +02:00

fix errors in comments and variable names

This commit is contained in:
mengxun 2025-07-07 11:46:21 +08:00
parent dcf879b836
commit 382845929c

View file

@ -108,9 +108,9 @@ func EncryptChaCha(plaintext []byte, aead cipher.AEAD) (encrypted []byte, err er
return return
} }
// DecryptChaCha will encrypt ChaCha20-Poly1305 using the pre-generated key // DecryptChaCha will decrypt ChaCha20-Poly1305 using the pre-generated key
// https://pkg.go.dev/golang.org/x/crypto/chacha20poly1305 // https://pkg.go.dev/golang.org/x/crypto/chacha20poly1305
func DecryptChaCha(encryptedMsg []byte, aead cipher.AEAD) (encrypted []byte, err error) { func DecryptChaCha(encryptedMsg []byte, aead cipher.AEAD) (plaintext []byte, err error) {
if len(encryptedMsg) < aead.NonceSize() { if len(encryptedMsg) < aead.NonceSize() {
err = fmt.Errorf("ciphertext too short") err = fmt.Errorf("ciphertext too short")
return return
@ -120,6 +120,6 @@ func DecryptChaCha(encryptedMsg []byte, aead cipher.AEAD) (encrypted []byte, err
nonce, ciphertext := encryptedMsg[:aead.NonceSize()], encryptedMsg[aead.NonceSize():] nonce, ciphertext := encryptedMsg[:aead.NonceSize()], encryptedMsg[aead.NonceSize():]
// Decrypt the message and check it wasn't tampered with. // Decrypt the message and check it wasn't tampered with.
encrypted, err = aead.Open(nil, nonce, ciphertext, nil) plaintext, err = aead.Open(nil, nonce, ciphertext, nil)
return return
} }