mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-15 05:31:18 +08:00
24 lines
436 B
Go
24 lines
436 B
Go
package shadowstream
|
|
|
|
import (
|
|
"crypto/cipher"
|
|
|
|
"github.com/metacubex/chacha"
|
|
)
|
|
|
|
type chacha20key []byte
|
|
|
|
func (k chacha20key) IVSize() int {
|
|
return chacha.NonceSize
|
|
}
|
|
func (k chacha20key) Encrypter(iv []byte) cipher.Stream {
|
|
c, _ := chacha.NewChaCha20(iv, k)
|
|
return c
|
|
}
|
|
func (k chacha20key) Decrypter(iv []byte) cipher.Stream {
|
|
return k.Encrypter(iv)
|
|
}
|
|
func ChaCha20(key []byte) (Cipher, error) {
|
|
return chacha20key(key), nil
|
|
}
|