chacha20.go 405 B

12345678910111213
  1. package crypto
  2. import (
  3. "crypto/cipher"
  4. "github.com/xtls/xray-core/common/crypto/internal"
  5. )
  6. // NewChaCha20Stream creates a new Chacha20 encryption/descryption stream based on give key and IV.
  7. // Caller must ensure the length of key is 32 bytes, and length of IV is either 8 or 12 bytes.
  8. func NewChaCha20Stream(key []byte, iv []byte) cipher.Stream {
  9. return internal.NewChaCha20Stream(key, iv, 20)
  10. }