Class Util
Utilities that are used during compression
Inheritance
Inherited Members
Namespace: CSChaCha20
Assembly: cs.temp.dll.dll
Syntax
public static class Util
Methods
Add(UInt32, UInt32)
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 |
---|---|---|
System.UInt32 | v | |
System.UInt32 | w |
Returns
Type | Description |
---|---|
System.UInt32 | The result of (v + w) modulo 2^32 |
Remarks
AddOne(UInt32)
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 |
---|---|---|
System.UInt32 | v |
Returns
Type | Description |
---|---|
System.UInt32 | The result of (v + 1) modulo 2^32 |
Remarks
Rotate(UInt32, Int32)
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 |
---|---|---|
System.UInt32 | v | |
System.Int32 | c |
Returns
Type | Description |
---|---|
System.UInt32 | The result of (v LEFTSHIFT c) |
ToBytes(Byte[], UInt32, Int32)
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 |
---|---|---|
System.Byte[] | output | |
System.UInt32 | input | |
System.Int32 | outputOffset |
U8To32Little(Byte[], Int32)
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 |
---|---|---|
System.Byte[] | p | |
System.Int32 | inputOffset |
Returns
Type | Description |
---|---|
System.UInt32 | An unsigned 32-bit integer |
XOr(UInt32, UInt32)
Unchecked integer exclusive or (XOR) operation.
Declaration
public static uint XOr(uint v, uint w)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | v | |
System.UInt32 | w |
Returns
Type | Description |
---|---|
System.UInt32 | The result of (v XOR w) |