Implementation of the ChaCha20 cipher.
• new ChaCha20(key
, nonce
, counter?
)
Create a new instance of ChaCha20.
Name | Type | Default value | Description |
---|---|---|---|
key |
Uint8Array |
undefined |
The key. |
nonce |
Uint8Array |
undefined |
The nonce. |
counter |
number |
0 |
Counter. |
▸ encrypt(data
): Uint8Array
Encrypt the data.
Name | Type | Description |
---|---|---|
data |
Uint8Array |
The source data to encrypt. |
Uint8Array
The encrypted data.
▸ decrypt(data
): Uint8Array
Decrypt the data.
Name | Type | Description |
---|---|---|
data |
Uint8Array |
The source data to decrypt. |
Uint8Array
The decrypted data.
▸ keyStream(length
): Uint8Array
Create a keystream of the given length.
Name | Type | Description |
---|---|---|
length |
number |
The length to create the keystream. |
Uint8Array
The keystream.