github.com/xraypb/Xray-core@v1.8.1/common/crypto/chacha20.go (about)

     1  package crypto
     2  
     3  import (
     4  	"crypto/cipher"
     5  
     6  	"github.com/xraypb/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  }