Apply suggestion from @coderabbitai[bot]

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Snider 2025-10-30 19:21:44 +00:00 committed by GitHub
parent 0da27d9280
commit bbbbe68052
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -28,6 +28,9 @@ func Encrypt(plaintext []byte, key []byte) ([]byte, error) {
// Decrypt decrypts data using ChaCha20-Poly1305.
func Decrypt(ciphertext []byte, key []byte) ([]byte, error) {
if len(key) != chacha20poly1305.KeySize {
return nil, fmt.Errorf("invalid key size: got %d bytes, want %d bytes", len(key), chacha20poly1305.KeySize)
}
aead, err := chacha20poly1305.NewX(key)
if err != nil {
return nil, err