Class Util
Utilities that are used during compression
Inherited Members
Namespace: CSChaCha20
Assembly: .dll
Syntax
public static class Util
Methods
| Edit this page View SourceAdd(uint, uint)
Unchecked integer addition. The ChaCha spec defines certain operations to use 32-bit unsigned integer addition modulo 2^32.
Declaration
public static uint Add(uint v, uint w)
Parameters
Type | Name | Description |
---|---|---|
uint | v | |
uint | w |
Returns
Type | Description |
---|---|
uint | The result of (v + w) modulo 2^32 |
Remarks
| Edit this page View SourceAddOne(uint)
Add 1 to the input parameter using unchecked integer addition. The ChaCha spec defines certain operations to use 32-bit unsigned integer addition modulo 2^32.
Declaration
public static uint AddOne(uint v)
Parameters
Type | Name | Description |
---|---|---|
uint | v |
Returns
Type | Description |
---|---|
uint | The result of (v + 1) modulo 2^32 |
Remarks
| Edit this page View SourceRotate(uint, int)
n-bit left rotation operation (towards the high bits) for 32-bit integers.
Declaration
public static uint Rotate(uint v, int c)
Parameters
Type | Name | Description |
---|---|---|
uint | v | |
int | c |
Returns
Type | Description |
---|---|
uint | The result of (v LEFTSHIFT c) |
ToBytes(byte[], uint, int)
Serialize the input integer into the output buffer. The input integer will be split into 4 bytes and put into four sequential places in the output buffer, starting at the outputOffset.
Declaration
public static void ToBytes(byte[] output, uint input, int outputOffset)
Parameters
Type | Name | Description |
---|---|---|
byte[] | output | |
uint | input | |
int | outputOffset |
U8To32Little(byte[], int)
Convert four bytes of the input buffer into an unsigned 32-bit integer, beginning at the inputOffset.
Declaration
public static uint U8To32Little(byte[] p, int inputOffset)
Parameters
Type | Name | Description |
---|---|---|
byte[] | p | |
int | inputOffset |
Returns
Type | Description |
---|---|
uint | An unsigned 32-bit integer |
XOr(uint, uint)
Unchecked integer exclusive or (XOR) operation.
Declaration
public static uint XOr(uint v, uint w)
Parameters
Type | Name | Description |
---|---|---|
uint | v | |
uint | w |
Returns
Type | Description |
---|---|
uint | The result of (v XOR w) |