go1.20.5
GoThrough

chacha20.KeySize

// KeySize is the size of the key used by this cipher, in bytes. const KeySize = 32

chacha20.NonceSize

// NonceSize is the size of the nonce used with the standard variant of this // cipher, in bytes. // // Note that this is too short to be safely generated at random if the same // key is reused more than 2³² times. const NonceSize = 12

chacha20.NonceSizeX

// NonceSizeX is the size of the nonce used with the XChaCha20 variant of // this cipher, in bytes. const NonceSizeX = 24

chacha20.HChaCha20

// HChaCha20 uses the ChaCha20 core to generate a derived key from a 32 bytes // key and a 16 bytes nonce. It returns an error if key or nonce have any other // length. It is used as part of the XChaCha20 construction. func HChaCha20(key []byte, nonce []byte) ([]byte, error)

chacha20.NewUnauthenticatedCipher

// NewUnauthenticatedCipher creates a new ChaCha20 stream cipher with the given // 32 bytes key and a 12 or 24 bytes nonce. If a nonce of 24 bytes is provided, // the XChaCha20 construction will be used. It returns an error if key or nonce // have any other length. // // Note that ChaCha20, like all stream ciphers, is not authenticated and allows // attackers to silently tamper with the plaintext. For this reason, it is more // appropriate as a building block than as a standalone encryption mechanism. // Instead, consider using package golang.org/x/crypto/chacha20poly1305. func NewUnauthenticatedCipher(key []byte, nonce []byte) (*Cipher, error)