github.com/xtls/xray-core@v1.8.12-0.20240518155711-3168d27b0bdb/common/crypto/chacha20.go (about)

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