• Api Documentation
Show / Hide Table of Contents
  • CS_AES_CTR
    • AES_CTR

Class AES_CTR

Class that can be used for AES CTR encryption / decryption

Inheritance
object
AES_CTR
Implements
IDisposable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: CS_AES_CTR
Assembly: .dll
Syntax
public sealed class AES_CTR : IDisposable

Constructors

| Edit this page View Source

AES_CTR(byte[], byte[], bool)

AES_CTR constructor

Declaration
public AES_CTR(byte[] key, byte[] initialCounter, bool littleEndian = false)
Parameters
Type Name Description
byte[] key

Key as byte array. (128, 192 or 256 bits)

byte[] initialCounter

Initial counter as byte array. 16 bytes

bool littleEndian

Is initial counter little endian (default false)

| Edit this page View Source

AES_CTR(ReadOnlySpan<byte>, ReadOnlySpan<byte>, bool)

AES_CTR constructor

Declaration
public AES_CTR(ReadOnlySpan<byte> key, ReadOnlySpan<byte> initialCounter, bool littleEndian = false)
Parameters
Type Name Description
ReadOnlySpan<byte> key

Key as readonlyspan. (128, 192 or 256 bits)

ReadOnlySpan<byte> initialCounter

Initial counter as readonlyspan. 16 bytes

bool littleEndian

Is initial counter little endian (default false)

Fields

| Edit this page View Source

allowedCounterLength

What is allowed initial counter length in bytes

Declaration
public const int allowedCounterLength = 16
Field Value
Type Description
int
| Edit this page View Source

allowedKeyLengths

What are allowed key lengths in bytes (128, 192 and 256 bits)

Declaration
public static readonly ImmutableArray<int> allowedKeyLengths
Field Value
Type Description
ImmutableArray<int>

Methods

| Edit this page View Source

DecryptBytes(byte[], bool)

Decrypt arbitrary-length byte array (input), writing the resulting byte array that is allocated by method.

Declaration
public byte[] DecryptBytes(byte[] input, bool useSIMD = true)
Parameters
Type Name Description
byte[] input

Input byte array

bool useSIMD

Use SIMD (true by default)

Returns
Type Description
byte[]

Byte array that contains decrypted bytes

Remarks

Since this is symmetric operation, it doesn't really matter if you use Encrypt or Decrypt method

| Edit this page View Source

DecryptBytes(byte[], byte[], bool)

Decrypt arbitrary-length byte array (input), writing the resulting byte array to preallocated output buffer.

Declaration
public void DecryptBytes(byte[] output, byte[] input, bool useSIMD = true)
Parameters
Type Name Description
byte[] output

Output byte array, must have enough bytes

byte[] input

Input byte array

bool useSIMD

Use SIMD (true by default)

Remarks

Since this is symmetric operation, it doesn't really matter if you use Encrypt or Decrypt method

| Edit this page View Source

DecryptBytes(byte[], byte[], int, bool)

Decrypt arbitrary-length byte array (input), writing the resulting byte array to preallocated output buffer.

Declaration
public void DecryptBytes(byte[] output, byte[] input, int numBytes, bool useSIMD = true)
Parameters
Type Name Description
byte[] output

Output byte array, must have enough bytes

byte[] input

Input byte array

int numBytes

Number of bytes to encrypt

bool useSIMD

Use SIMD (true by default)

Remarks

Since this is symmetric operation, it doesn't really matter if you use Encrypt or Decrypt method

| Edit this page View Source

DecryptBytes(byte[], int, bool)

Decrypt arbitrary-length byte array (input), writing the resulting byte array that is allocated by method.

Declaration
public byte[] DecryptBytes(byte[] input, int numBytes, bool useSIMD = true)
Parameters
Type Name Description
byte[] input

Input byte array

int numBytes

Number of bytes to encrypt

bool useSIMD

Use SIMD (true by default)

Returns
Type Description
byte[]

Byte array that contains decrypted bytes

Remarks

Since this is symmetric operation, it doesn't really matter if you use Encrypt or Decrypt method

| Edit this page View Source

DecryptStream(Stream, Stream, int, bool)

Decrypt arbitrary-length byte stream (input), writing the resulting bytes to another stream (output)

Declaration
public void DecryptStream(Stream output, Stream input, int howManyBytesToProcessAtTime = 1024, bool useSIMD = true)
Parameters
Type Name Description
Stream output

Output stream

Stream input

Input stream

int howManyBytesToProcessAtTime

How many bytes to read and write at time, default is 1024

bool useSIMD

Use SIMD (true by default)

| Edit this page View Source

DecryptStreamAsync(Stream, Stream, int, bool)

Async decrypt arbitrary-length byte stream (input), writing the resulting bytes to another stream (output)

Declaration
public Task DecryptStreamAsync(Stream output, Stream input, int howManyBytesToProcessAtTime = 1024, bool useSIMD = true)
Parameters
Type Name Description
Stream output

Output stream

Stream input

Input stream

int howManyBytesToProcessAtTime

How many bytes to read and write at time, default is 1024

bool useSIMD

Use SIMD (true by default)

Returns
Type Description
Task
| Edit this page View Source

DecryptUTF8ByteArray(byte[], bool)

Decrypt UTF8 byte array to string.

Declaration
public string DecryptUTF8ByteArray(byte[] input, bool useSIMD = true)
Parameters
Type Name Description
byte[] input

Byte array

bool useSIMD

Use SIMD (true by default)

Returns
Type Description
string

Byte array that contains encrypted bytes

Remarks

Here you can NOT swap encrypt and decrypt methods, because of bytes-string transform

| Edit this page View Source

Dispose()

Clear and dispose of the internal state. Also request the GC not to call the finalizer, because all cleanup has been taken care of.

Declaration
public void Dispose()
| Edit this page View Source

EncryptBytes(byte[], bool)

Encrypt arbitrary-length byte array (input), writing the resulting byte array that is allocated by method.

Declaration
public byte[] EncryptBytes(byte[] input, bool useSIMD = true)
Parameters
Type Name Description
byte[] input

Input byte array

bool useSIMD

Use SIMD (true by default)

Returns
Type Description
byte[]

Byte array that contains encrypted bytes

Remarks

Since this is symmetric operation, it doesn't really matter if you use Encrypt or Decrypt method

| Edit this page View Source

EncryptBytes(byte[], byte[], bool)

Encrypt arbitrary-length byte array (input), writing the resulting byte array to preallocated output buffer.

Declaration
public void EncryptBytes(byte[] output, byte[] input, bool useSIMD = true)
Parameters
Type Name Description
byte[] output

Output byte array, must have enough bytes

byte[] input

Input byte array

bool useSIMD

Use SIMD (true by default)

Remarks

Since this is symmetric operation, it doesn't really matter if you use Encrypt or Decrypt method

| Edit this page View Source

EncryptBytes(byte[], byte[], int, bool)

Encrypt arbitrary-length byte array (input), writing the resulting byte array to preallocated output buffer.

Declaration
public void EncryptBytes(byte[] output, byte[] input, int numBytes, bool useSIMD = true)
Parameters
Type Name Description
byte[] output

Output byte array, must have enough bytes

byte[] input

Input byte array

int numBytes

Number of bytes to encrypt

bool useSIMD

Use SIMD (true by default)

Remarks

Since this is symmetric operation, it doesn't really matter if you use Encrypt or Decrypt method

| Edit this page View Source

EncryptBytes(byte[], int, bool)

Encrypt arbitrary-length byte array (input), writing the resulting byte array that is allocated by method.

Declaration
public byte[] EncryptBytes(byte[] input, int numBytes, bool useSIMD = true)
Parameters
Type Name Description
byte[] input

Input byte array

int numBytes

Number of bytes to encrypt

bool useSIMD

Use SIMD (true by default)

Returns
Type Description
byte[]

Byte array that contains encrypted bytes

Remarks

Since this is symmetric operation, it doesn't really matter if you use Encrypt or Decrypt method

| Edit this page View Source

EncryptStream(Stream, Stream, int, bool)

Encrypt arbitrary-length byte stream (input), writing the resulting bytes to another stream (output)

Declaration
public void EncryptStream(Stream output, Stream input, int howManyBytesToProcessAtTime = 1024, bool useSIMD = true)
Parameters
Type Name Description
Stream output

Output stream

Stream input

Input stream

int howManyBytesToProcessAtTime

How many bytes to read and write at time, default is 1024

bool useSIMD

Use SIMD (true by default)

| Edit this page View Source

EncryptStreamAsync(Stream, Stream, int, bool)

Async encrypt arbitrary-length byte stream (input), writing the resulting bytes to another stream (output)

Declaration
public Task EncryptStreamAsync(Stream output, Stream input, int howManyBytesToProcessAtTime = 1024, bool useSIMD = true)
Parameters
Type Name Description
Stream output

Output stream

Stream input

Input stream

int howManyBytesToProcessAtTime

How many bytes to read and write at time, default is 1024

bool useSIMD

Use SIMD (true by default)

Returns
Type Description
Task
| Edit this page View Source

EncryptString(string, bool)

Encrypt string as UTF8 byte array, returns byte array that is allocated by method.

Declaration
public byte[] EncryptString(string input, bool useSIMD = true)
Parameters
Type Name Description
string input

Input string

bool useSIMD

Use SIMD (true by default)

Returns
Type Description
byte[]

Byte array that contains encrypted bytes

Remarks

Here you can NOT swap encrypt and decrypt methods, because of bytes-string transform

| Edit this page View Source

~AES_CTR()

Clear and dispose of the internal variables. The finalizer is only called if Dispose() was never called on this cipher.

Declaration
protected ~AES_CTR()

Implements

IDisposable
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX