ChaCha20

Implementation of ChaCha20 digester.

ChaCha20 is a symmetric encryption algorithm designed to provide both high performance and high security. It operates on 512-bit (64-byte) blocks and accepts a 256-bit (32-byte) key and a 96-bit (12-byte) nonce.

Members

Static functions

decrypt
void decrypt(ubyte[] data, string key, ubyte[12] nonce, uint counter)

Decrypts the given byte array data.

encrypt
void encrypt(ubyte[] data, string key, ubyte[12] nonce, uint counter)

Encrypts the given byte array data.

Examples

import tern.digest.chacha20;

ubyte[] data = [1, 2, 3, 4, 5];
string key = "my_secret_key"; // Must be exactly 256 bits (32 bytes) in length.
ubyte[12] nonce = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // Must be exactly 96 bits (12 bytes) in length.
uint counter = 0;
ChaCha20.encrypt(data, key, nonce, counter);

Meta