|
@@ -5,11 +5,15 @@ import (
|
|
|
"crypto/cipher"
|
|
"crypto/cipher"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+// NewAesDecryptionStream creates a new AES encryption stream based on given key and IV.
|
|
|
|
|
+// Caller must ensure the length of key and IV is either 16, 24 or 32 bytes.
|
|
|
func NewAesDecryptionStream(key []byte, iv []byte) cipher.Stream {
|
|
func NewAesDecryptionStream(key []byte, iv []byte) cipher.Stream {
|
|
|
aesBlock, _ := aes.NewCipher(key)
|
|
aesBlock, _ := aes.NewCipher(key)
|
|
|
return cipher.NewCFBDecrypter(aesBlock, iv)
|
|
return cipher.NewCFBDecrypter(aesBlock, iv)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// NewAesEncryptionStream creates a new AES description stream based on given key and IV.
|
|
|
|
|
+// Caller must ensure the length of key and IV is either 16, 24 or 32 bytes.
|
|
|
func NewAesEncryptionStream(key []byte, iv []byte) cipher.Stream {
|
|
func NewAesEncryptionStream(key []byte, iv []byte) cipher.Stream {
|
|
|
aesBlock, _ := aes.NewCipher(key)
|
|
aesBlock, _ := aes.NewCipher(key)
|
|
|
return cipher.NewCFBEncrypter(aesBlock, iv)
|
|
return cipher.NewCFBEncrypter(aesBlock, iv)
|