mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-06-02 17:29:08 -04:00
refactor
This commit is contained in:
@@ -3,15 +3,15 @@ package crypto
|
||||
import (
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
|
||||
"v2ray.com/core/common"
|
||||
)
|
||||
|
||||
// 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 {
|
||||
aesBlock, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
common.Must(err)
|
||||
return cipher.NewCFBDecrypter(aesBlock, iv)
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@ func NewAesDecryptionStream(key []byte, iv []byte) cipher.Stream {
|
||||
// Caller must ensure the length of key and IV is either 16, 24 or 32 bytes.
|
||||
func NewAesEncryptionStream(key []byte, iv []byte) cipher.Stream {
|
||||
aesBlock, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
common.Must(err)
|
||||
return cipher.NewCFBEncrypter(aesBlock, iv)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user