Skip to content

Commit 0e94fa1

Browse files
authored
Merge pull request #934 from mengxunQAQ/main
fix errors in comments and variable names
2 parents 4b24af8 + 5ca1603 commit 0e94fa1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/compress/compress.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func CompressWithOption(src []byte, level int) []byte {
1818
// Compress returns a compressed byte slice.
1919
func Compress(src []byte) []byte {
2020
compressedData := new(bytes.Buffer)
21-
compress(src, compressedData, -2)
21+
compress(src, compressedData, flate.HuffmanOnly)
2222
return compressedData.Bytes()
2323
}
2424

src/crypt/crypt.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ func EncryptChaCha(plaintext []byte, aead cipher.AEAD) (encrypted []byte, err er
108108
return
109109
}
110110

111-
// DecryptChaCha will encrypt ChaCha20-Poly1305 using the pre-generated key
111+
// DecryptChaCha will decrypt ChaCha20-Poly1305 using the pre-generated key
112112
// https://pkg.go.dev/golang.org/x/crypto/chacha20poly1305
113-
func DecryptChaCha(encryptedMsg []byte, aead cipher.AEAD) (encrypted []byte, err error) {
113+
func DecryptChaCha(encryptedMsg []byte, aead cipher.AEAD) (plaintext []byte, err error) {
114114
if len(encryptedMsg) < aead.NonceSize() {
115115
err = fmt.Errorf("ciphertext too short")
116116
return
@@ -120,6 +120,6 @@ func DecryptChaCha(encryptedMsg []byte, aead cipher.AEAD) (encrypted []byte, err
120120
nonce, ciphertext := encryptedMsg[:aead.NonceSize()], encryptedMsg[aead.NonceSize():]
121121

122122
// Decrypt the message and check it wasn't tampered with.
123-
encrypted, err = aead.Open(nil, nonce, ciphertext, nil)
123+
plaintext, err = aead.Open(nil, nonce, ciphertext, nil)
124124
return
125125
}

0 commit comments

Comments
 (0)