diff --git a/src/compress/compress.go b/src/compress/compress.go index 465f2c99..5e2369fd 100644 --- a/src/compress/compress.go +++ b/src/compress/compress.go @@ -18,7 +18,7 @@ func CompressWithOption(src []byte, level int) []byte { // Compress returns a compressed byte slice. func Compress(src []byte) []byte { compressedData := new(bytes.Buffer) - compress(src, compressedData, -2) + compress(src, compressedData, flate.HuffmanOnly) return compressedData.Bytes() } diff --git a/src/crypt/crypt.go b/src/crypt/crypt.go index 22b9b888..e2354105 100644 --- a/src/crypt/crypt.go +++ b/src/crypt/crypt.go @@ -108,9 +108,9 @@ func EncryptChaCha(plaintext []byte, aead cipher.AEAD) (encrypted []byte, err er 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 -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() { err = fmt.Errorf("ciphertext too short") return @@ -120,6 +120,6 @@ func DecryptChaCha(encryptedMsg []byte, aead cipher.AEAD) (encrypted []byte, err nonce, ciphertext := encryptedMsg[:aead.NonceSize()], encryptedMsg[aead.NonceSize():] // 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 }