CryptoSys API .NET Class Library 6.22.1

Classes | Methods | Enumerations | Index
CryptoSysAPI Namespace

.NET interface to CryptoSys API.

Classes

Methods

Aead Class Methods

Aes128 Class Methods

Aes192 Class Methods

Aes256 Class Methods

Blowfish Class Methods

Cipher Class Methods

CipherStream Class Methods

Cnv Class Methods

Compr Class Methods

Crc Class Methods

Des Class Methods

Gcm Class Methods

General Class Methods

Hash Class Methods

Mac Class Methods

Md5 Class Methods

Pbe Class Methods

Pc1 Class Methods

Prf Class Methods

Rng Class Methods

Sha1 Class Methods

Sha256 Class Methods

Sha3 Class Methods

Tdea Class Methods

Wipe Class Methods

Xof Class Methods

Zlib Class Methods


Aead.AddAAD Method

Add a chunk of additional authenticated data (in incremental mode)

Syntax

[C#]
public int AddAAD(
	byte[] aad
)
[VB.NET]
Public Function AddAAD ( _
	aad As Byte() _
) As Integer

Parameters

aad
Chunk of additional data to add

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

May be repeated to add additional data in chunks. Must eventually be followed by either StartEncrypt() or StartDecrypt().

Aead.Authenticate Method

Authenticate additional data using tag

Syntax

[C#]
public static bool Authenticate(
	byte[] key,
	byte[] nonce,
	byte[] aad,
	byte[] tag,
	Aead.Algorithm alg
)
[VB.NET]
Public Shared Function Authenticate ( _
	key As Byte(), _
	nonce As Byte(), _
	aad As Byte(), _
	tag As Byte(), _
	alg As Aead.Algorithm _
) As Boolean

Parameters

key
Key of exact length for given algorithm (16 or 32 bytes).
nonce
Nonce of exact length for given algorithm (currently always 12 bytes)
aad
Data to be authenticated
tag
Tag value
alg
Type: Aead.Algorithm
AEAD algorithm to use

Return Value

True if authentication is valid; false if failed or an error occurred.

Remarks

Use General.ErrorCode to find the code of the last error. This is equivalent to Aead.Decrypt with a zero-length ciphertext input.

Aead.Decrypt Method

Decrypt and authenticate input using specified AEAD algorithm in one-off operation

Syntax

[C#]
public static byte[] Decrypt(
	byte[] input,
	byte[] key,
	byte[] nonce,
	byte[] aad,
	byte[] tag,
	Aead.Algorithm alg
)
[VB.NET]
Public Shared Function Decrypt ( _
	input As Byte(), _
	key As Byte(), _
	nonce As Byte(), _
	aad As Byte(), _
	tag As Byte(), _
	alg As Aead.Algorithm _
) As Byte()

Parameters

input
Cipher text input data (required)
key
Key of exact length for given algorithm (16 or 32 bytes).
nonce
Nonce of exact length for given algorithm (currently always 12 bytes).
aad
Additional authentication data (optional). Pass null/Nothing to ignore.
tag
Tag value (required)
alg
Type: Aead.Algorithm
AEAD algorithm to use

Return Value

Decrypted plaintext in byte array, or empty array on error

Remarks

Use General.ErrorCode to find the code of the last error. The plaintext is always the same length as the ciphertext. The tag must be input separately.

Aead.DecryptWithTag Method (Byte[], Byte[], Byte[], Aead.Algorithm)

Decrypt data using specified AEAD algorithm in one-off operation. The authentication tag is expected to be appended to the input ciphertext.

Syntax

[C#]
public static byte[] DecryptWithTag(
	byte[] input,
	byte[] key,
	byte[] iv,
	Aead.Algorithm aeadAlg
)
[VB.NET]
Public Shared Function DecryptWithTag ( _
	input As Byte(), _
	key As Byte(), _
	iv As Byte(), _
	aeadAlg As Aead.Algorithm _
) As Byte()

Parameters

input
Input data to be decrypted.
key
Key of exact length for algorithm (16 or 32 bytes).
iv
Initialization Vector (IV) (aka nonce) (12 or 16 bytes).
aeadAlg
Type: Aead.Algorithm
Authenticated encryption algorithm.

Return Value

Plaintext in a byte array, or empty array on error (an empty array may also be the correct result - check General.ErrorCode for details).

Remarks

The input must include the 16-byte tag appended to the ciphertext. The output will be exactly 16 bytes shorter than the input. In all cases the tag must be exactly 16 bytes (128 bits). The IV must be 16 bytes (128 bits) for ASCON-128 otherwise 12 bytes (96 bits).

Aead.DecryptWithTag Method (Byte[], Byte[], Byte[], Byte[], Aead.Algorithm, Aead.Opts)

Decrypt data using specified AEAD algorithm in one-off operation with AAD and options. The authentication tag is expected to be appended to the input ciphertext.

Syntax

[C#]
public static byte[] DecryptWithTag(
	byte[] input,
	byte[] key,
	byte[] iv,
	byte[] aad,
	Aead.Algorithm aeadAlg,
	Aead.Opts opts
)
[VB.NET]
Public Shared Function DecryptWithTag ( _
	input As Byte(), _
	key As Byte(), _
	iv As Byte(), _
	aad As Byte(), _
	aeadAlg As Aead.Algorithm, _
	opts As Aead.Opts _
) As Byte()

Parameters

input
Input data to be decrypted.
key
Key of exact length for algorithm (16 or 32 bytes).
iv
(optional) Initialization Vector (IV) (aka nonce) exactly 12 bytes long. Set as null if already prefixed to input.
aad
Additional authenticated data (optional) - set as null to ignore.
aeadAlg
Type: Aead.Algorithm
Authenticated encryption algorithm.
opts
Type: Aead.Opts
Advanced options. Use Aead.Opts.PrefixIV to expect the IV to be prepended at the start of the input.

Return Value

Plaintext in a byte array, or empty array on error (an empty array may also be the correct result - check General.ErrorCode for details).

Remarks

The input must include the 16-byte tag appended to the ciphertext and may include a 12-byte prefixed IV. The output will either be exactly 16 bytes shorter than the input, or exactly 28 bytes shorter if the Cipher.Opts.PrefixIV option is used. In all cases the tag must be exactly 16 bytes (128 bits). The IV must be 16 bytes (128 bits) for ASCON-128 otherwise 12 bytes (96 bits). If additional authentication data (AAD) was provided during encryption then the exact same AAD data must be provided here.

Aead.Dispose Method

Dispose of this object and clear any key schedules

Syntax

[C#]
public void Dispose()
[VB.NET]
Public Sub Dispose

Aead.Encrypt Method

Encrypt input using specified AEAD algorithm in one-off operation.

Syntax

[C#]
public static byte[] Encrypt(
	out byte[] tag,
	byte[] input,
	byte[] key,
	byte[] nonce,
	byte[] aad,
	Aead.Algorithm alg
)
[VB.NET]
Public Shared Function Encrypt ( _
	<OutAttribute> ByRef tag As Byte(), _
	input As Byte(), _
	key As Byte(), _
	nonce As Byte(), _
	aad As Byte(), _
	alg As Aead.Algorithm _
) As Byte()

Parameters

tag
To receive the output authentication tag value. Currently always returned exactly 16 bytes long. This is a by-reference parameter. There is no need to initialize (but the VB compiler may complain).
input
Plain text input data (required)
key
Key of exact length for given algorithm (16 or 32 bytes)
nonce
Nonce of exact length for given algorithm (currently always 12 bytes)
aad
Additional authentication data (optional). Pass null/Nothing to ignore.
alg
Type: Aead.Algorithm
AEAD algorithm to use

Return Value

Encrypted ciphertext in byte array, or empty array on error

Remarks

Use General.ErrorCode to find the code of the last error. The ciphertext is always the same length as the plaintext. The authentication tag is output separately.

Aead.EncryptWithTag Method (Byte[], Byte[], Byte[], Aead.Algorithm)

Encrypt data using specified AEAD algorithm in one-off operation. The authentication tag is appended to the output.

Syntax

[C#]
public static byte[] EncryptWithTag(
	byte[] input,
	byte[] key,
	byte[] iv,
	Aead.Algorithm aeadAlg
)
[VB.NET]
Public Shared Function EncryptWithTag ( _
	input As Byte(), _
	key As Byte(), _
	iv As Byte(), _
	aeadAlg As Aead.Algorithm _
) As Byte()

Parameters

input
Input data to be encrypted.
key
Key of exact length for algorithm (16 or 32 bytes).
iv
Initialization Vector (IV) (aka nonce) (16 bytes for ASCON-128 else 12 bytes).
aeadAlg
Type: Aead.Algorithm
Authenticated encryption algorithm.

Return Value

Ciphertext with tag appended in a byte array, or empty array on error.

Remarks

The output will be exactly 16 bytes longer than the input.

Aead.EncryptWithTag Method (Byte[], Byte[], Byte[], Byte[], Aead.Algorithm, Aead.Opts)

Encrypt data using specified AEAD algorithm in one-off operation with AAD and options. The authentication tag is appended to the output.

Syntax

[C#]
public static byte[] EncryptWithTag(
	byte[] input,
	byte[] key,
	byte[] iv,
	byte[] aad,
	Aead.Algorithm aeadAlg,
	Aead.Opts opts
)
[VB.NET]
Public Shared Function EncryptWithTag ( _
	input As Byte(), _
	key As Byte(), _
	iv As Byte(), _
	aad As Byte(), _
	aeadAlg As Aead.Algorithm, _
	opts As Aead.Opts _
) As Byte()

Parameters

input
Input data to be encrypted.
key
Key of exact length for algorithm (16 or 32 bytes).
iv
Initialization Vector (IV) (aka nonce) (16 bytes for ASCON-128 else 12 bytes).
aad
Additional authenticated data (optional) - set as null to ignore.
aeadAlg
Type: Aead.Algorithm
Authenticated encryption algorithm.
opts
Type: Aead.Opts
Advanced options (optional). Use Opts.PrefixIV to prepend the IV to the output

Return Value

Ciphertext with tag appended in a byte array, or empty array on error.

Remarks

The output will either be exactly 16 bytes longer than the input, or 28/32 bytes longer if Aead.Opts.PrefixIV is used.

Aead.FinishDecrypt Method

Finishes the authenticated decryption (in incremental mode)

Syntax

[C#]
public bool FinishDecrypt()
[VB.NET]
Public Function FinishDecrypt As Boolean

Return Value

True if the decryption is authenticated; false otherwise.

Remarks

Must be preceded by StartDecrypt() and zero or more calls to Update(). May be followed by SetNonce() to begin processing another packet with the same key and algorithm; otherwise should be followed by Dispose().

Aead.FinishEncrypt Method

Finishes the authenticated encryption (in incremental mode)

Syntax

[C#]
public byte[] FinishEncrypt()
[VB.NET]
Public Function FinishEncrypt As Byte()

Return Value

Authentication tag value

Remarks

Must be preceded by StartEncrypt() and zero or more calls to Update(). May be followed by SetNonce() to begin processing another packet with the same key and algorithm; otherwise should be followed by Dispose().

Aead.InitKey Method

Initializes the context with the key and algorithm ready for repeated incremental operations

Syntax

[C#]
public int InitKey(
	byte[] key,
	Aead.Algorithm alg
)
[VB.NET]
Public Function InitKey ( _
	key As Byte(), _
	alg As Aead.Algorithm _
) As Integer

Parameters

key
Key of exact length for given algorithm (16 or 32 bytes).
alg
Type: Aead.Algorithm
AEAD algorithm to use

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

Must be followed by SetNonce(). Can be called at any time to cancel any previous incremental settings.

Example

[C#]
Aead o = Aead.Instance();
o.InitKey(key, alg);
o.SetNonce(nonce);
//...
o.Dispose();

Aead.Instance Method

Create the one and only instance

Syntax

[C#]
public static Aead Instance()
[VB.NET]
Public Shared Function Instance As Aead

Return Value

Single instance to class

Aead.Mac Method

Compute Message Authentication Code (tag) over input data

Syntax

[C#]
public static byte[] Mac(
	byte[] key,
	byte[] nonce,
	byte[] aad,
	Aead.Algorithm alg
)
[VB.NET]
Public Shared Function Mac ( _
	key As Byte(), _
	nonce As Byte(), _
	aad As Byte(), _
	alg As Aead.Algorithm _
) As Byte()

Parameters

key
Key of exact length for given algorithm (16 or 32 bytes).
nonce
Nonce of exact length for given algorithm (currently always 12 bytes)
aad
Data to be authenticated
alg
Type: Aead.Algorithm
AEAD algorithm to use

Return Value

Tag value in byte array, or empty array on error

Remarks

Use General.ErrorCode to find the code of the last error. This is equivalent to Aead.Encrypt with a zero-length plaintext input.

Aead.SetNonce Method

Set the nonce (in incremental mode)

Syntax

[C#]
public int SetNonce(
	byte[] nonce
)
[VB.NET]
Public Function SetNonce ( _
	nonce As Byte() _
) As Integer

Parameters

nonce
Nonce of exact length for given algorithm (currently always 12 bytes)

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

May be followed by zero or more calls to AddAAD() and then either StartEncrypt() or StartDecrypt().

Aead.StartDecrypt Method

Start authenticated decryption (in incremental mode)

Syntax

[C#]
public int StartDecrypt(
	byte[] tagToCheck
)
[VB.NET]
Public Function StartDecrypt ( _
	tagToCheck As Byte() _
) As Integer

Parameters

tagToCheck
Tag value to be authenticated

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

May be followed by zero or more calls to Update() to decrypt data in chunks. Must eventually be followed by FinishDecrypt(). Caution: do not trust decrypted data until final authentication.

Aead.StartEncrypt Method

Start authenticated encryption (in incremental mode)

Syntax

[C#]
public int StartEncrypt()
[VB.NET]
Public Function StartEncrypt As Integer

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

May be followed by zero or more calls to Update() to encrypt data in chunks. Must eventually be followed by FinishEncrypt().

Aead.Update Method

Encrypts or decrypts a chunk of input (in incremental mode)

Syntax

[C#]
public byte[] Update(
	byte[] input
)
[VB.NET]
Public Function Update ( _
	input As Byte() _
) As Byte()

Parameters

input
Data to be encrypted or decrypted

Return Value

Encrypted or decrypted data in array of exactly the same length as input; or an empty array on error

Remarks

This function may be repeated to add data in chunks. The input data is encrypted or decrypted depending on the start mode set by a preceding call to StartEncrypt() or StartDecrypt(), respectively. It must eventually be followed by either FinishEncrypt() or FinishDecrypt(), which must match the start mode.

Aes128.Decrypt Method (Byte[], Byte[], Mode, Byte[])

Decrypt data in byte array

Syntax

[C#]
public static byte[] Decrypt(
	byte[] input,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function Decrypt ( _
	input As Byte(), _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Byte()

Parameters

input
Input data
key
Key of exactly 16 bytes (128 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Decrypted data in byte array or empty array on error

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (16 bytes)

Aes128.Decrypt Method (String, String, Mode, String)

Decrypt hex-encoded data string

Syntax

[C#]
public static string Decrypt(
	string inputHex,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function Decrypt ( _
	inputHex As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As String

Parameters

inputHex
Hex-encoded input data
keyHex
Hex-encoded key representing exactly 16 bytes (128 bits)
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV representing exactly 16 bytes or "" for ECB mode

Return Value

Decrypted data in hex-encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (16 bytes)

Aes128.Decrypt Method (String, String, Mode, String, EncodingBase)

Decrypt encoded data string

Syntax

[C#]
public static string Decrypt(
	string inputStr,
	string keyStr,
	Mode mode,
	string ivStr,
	EncodingBase encodingBase
)
[VB.NET]
Public Shared Function Decrypt ( _
	inputStr As String, _
	keyStr As String, _
	mode As Mode, _
	ivStr As String, _
	encodingBase As EncodingBase _
) As String

Parameters

inputStr
Encoded input data
keyStr
Encoded key representing exactly 16 bytes (128 bits)
mode
Type: Mode
Cipher Mode
ivStr
Encoded IV representing exactly 16 bytes or "" for ECB mode
encodingBase
Type: EncodingBase
Type of encoding used

Return Value

Decrypted data in encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (16 bytes)

Aes128.Dispose Method

Dispose of this object and clear any key schedules

Syntax

[C#]
public void Dispose()
[VB.NET]
Public Sub Dispose

Aes128.Encrypt Method (Byte[], Byte[], Mode, Byte[])

Encrypt data in byte array

Syntax

[C#]
public static byte[] Encrypt(
	byte[] input,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function Encrypt ( _
	input As Byte(), _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Byte()

Parameters

input
Input data
key
Key of exactly 16 bytes (128 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Ciphertext in byte array or empty array on error

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (16 bytes)

Aes128.Encrypt Method (String, String, Mode, String)

Encrypt hex-encoded data string

Syntax

[C#]
public static string Encrypt(
	string inputHex,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function Encrypt ( _
	inputHex As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As String

Parameters

inputHex
Hex-encoded input data
keyHex
Hex-encoded key representing exactly 16 bytes (128 bits)
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV representing exactly 16 bytes or "" for ECB mode

Return Value

Ciphertext in hex-encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (16 bytes)

Aes128.Encrypt Method (String, String, Mode, String, EncodingBase)

Encrypt encoded data string

Syntax

[C#]
public static string Encrypt(
	string inputStr,
	string keyStr,
	Mode mode,
	string ivStr,
	EncodingBase encodingBase
)
[VB.NET]
Public Shared Function Encrypt ( _
	inputStr As String, _
	keyStr As String, _
	mode As Mode, _
	ivStr As String, _
	encodingBase As EncodingBase _
) As String

Parameters

inputStr
Encoded input data
keyStr
Encoded key representing exactly 16 bytes (128 bits)
mode
Type: Mode
Cipher Mode
ivStr
Encoded IV representing exactly 16 bytes or "" for ECB mode
encodingBase
Type: EncodingBase
Type of encoding used

Return Value

Ciphertext in encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (16 bytes)

Aes128.FileDecrypt Method (String, String, Byte[], Mode, Byte[])

Decrypt a file

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 16 bytes (128 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Aes128.FileDecrypt Method (String, String, Byte[], Mode, Byte[], CipherFileOption)

Decrypt a file with advanced options

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv,
	CipherFileOption advOptions
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte(), _
	advOptions As CipherFileOption _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 16 bytes (128 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes. Use null/Nothing for ECB mode or when using CipherFileOption.PrefixIV option
advOptions
Type: CipherFileOption
Advanced options. See CipherFileOption.

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Aes128.FileDecrypt Method (String, String, String, Mode, String)

Decrypt a file passing key and IV as hex strings

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
keyHex
Hex-encoded key of exact length
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV or "" for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same. The output file is in binary format.

Aes128.FileEncrypt Method (String, String, Byte[], Mode, Byte[])

Encrypt a file

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 16 bytes (128 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Aes128.FileEncrypt Method (String, String, Byte[], Mode, Byte[], CipherFileOption)

Encrypt a file with advanced options

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv,
	CipherFileOption advOptions
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte(), _
	advOptions As CipherFileOption _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 16 bytes (128 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode
advOptions
Type: CipherFileOption
Advanced options. See CipherFileOption.

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Aes128.FileEncrypt Method (String, String, String, Mode, String)

Encrypt a file passing key and IV as hex strings

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
keyHex
Hex-encoded key of exact length
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV or "" for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same. The output file is in binary format.

Aes128.InitDecrypt Method (Byte[], Mode, Byte[])

Initializes with key, mode and IV ready to start decrypting

Syntax

[C#]
public int InitDecrypt(
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Function InitDecrypt ( _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

key
Key of exactly 16 bytes (128 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Aes128.InitDecrypt Method (String, Mode, String)

Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

[C#]
public int InitDecrypt(
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Function InitDecrypt ( _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

keyHex
Key in hex-encoded format
mode
Type: Mode
Cipher mode
ivHex
IV in hex-encoded format

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Aes128.InitEncrypt Method (Byte[], Mode, Byte[])

Initializes with key, mode and IV ready to start encrypting

Syntax

[C#]
public int InitEncrypt(
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Function InitEncrypt ( _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

key
Key of exactly 16 bytes (128 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Aes128.InitEncrypt Method (String, Mode, String)

Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

[C#]
public int InitEncrypt(
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Function InitEncrypt ( _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

keyHex
Key in hex-encoded format
mode
Type: Mode
Cipher mode
ivHex
IV in hex-encoded format

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Aes128.Instance Method

Create the one and only instance

Syntax

[C#]
public static Aes128 Instance()
[VB.NET]
Public Shared Function Instance As Aes128

Return Value

Single instance to class

Remarks

CAUTION: Instances of Aes128, Aes192 and Aes256 are not independent in the same thread.

Aes128.Pad Method (Byte[])

Pads byte array to correct length for ECB and CBC encryption

Syntax

[C#]
public static byte[] Pad(
	byte[] data
)
[VB.NET]
Public Shared Function Pad ( _
	data As Byte() _
) As Byte()

Parameters

data
data to be padded

Return Value

padded data in byte array

Remarks

Uses PKCS#5/#7/CMS method of padding

Aes128.Pad Method (String)

Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

[C#]
public static string Pad(
	string dataHex
)
[VB.NET]
Public Shared Function Pad ( _
	dataHex As String _
) As String

Parameters

dataHex
hex-encoded data to be padded

Return Value

padded data in hex-encoded string

Remarks

Uses PKCS#5/#7/CMS method of padding

Aes128.Unpad Method (Byte[])

Removes the padding from an encryption block

Syntax

[C#]
public static byte[] Unpad(
	byte[] data
)
[VB.NET]
Public Shared Function Unpad ( _
	data As Byte() _
) As Byte()

Parameters

data
padded data

Return Value

Unpadded data in byte array or unchanged data on error

Remarks

Padding is expected according to the convention in PKCS#5/#7/CMS. An error is indicated by returning the original data which will always be longer than the expected unpadded result.

Aes128.Unpad Method (String)

Removes the padding from a hex-encoded encryption block

Syntax

[C#]
public static string Unpad(
	string dataHex
)
[VB.NET]
Public Shared Function Unpad ( _
	dataHex As String _
) As String

Parameters

dataHex
hex-encoded padded data

Return Value

Unpadded data in hex-encoded string or unchanged data on error

Remarks

Padding is expected according to the convention in PKCS#5/#7/CMS. An error is indicated by returning the original data which will always be longer than the expected unpadded result.

Aes128.Update Method (Byte[])

Transform byte input data with previously initialized key, mode and direction

Syntax

[C#]
public byte[] Update(
	byte[] data
)
[VB.NET]
Public Function Update ( _
	data As Byte() _
) As Byte()

Parameters

data
input data in byte array

Return Value

transformed data in byte array

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (16 bytes)

Aes128.Update Method (String)

Transform hex string data with previously initialized key, mode and direction

Syntax

[C#]
public string Update(
	string data
)
[VB.NET]
Public Function Update ( _
	data As String _
) As String

Parameters

data
hex-encoded input data

Return Value

hex-encoded data

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (16 bytes)

Aes192.Decrypt Method (Byte[], Byte[], Mode, Byte[])

Decrypt data in byte array

Syntax

[C#]
public static byte[] Decrypt(
	byte[] input,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function Decrypt ( _
	input As Byte(), _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Byte()

Parameters

input
Input data
key
Key of exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Decrypted data in byte array or empty array on error

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (16 bytes)

Aes192.Decrypt Method (String, String, Mode, String)

Decrypt hex-encoded data string

Syntax

[C#]
public static string Decrypt(
	string inputHex,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function Decrypt ( _
	inputHex As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As String

Parameters

inputHex
Hex-encoded input data
keyHex
Hex-encoded key representing exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV representing exactly 16 bytes or "" for ECB mode

Return Value

Decrypted data in hex-encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (16 bytes)

Aes192.Decrypt Method (String, String, Mode, String, EncodingBase)

Decrypt encoded data string

Syntax

[C#]
public static string Decrypt(
	string inputStr,
	string keyStr,
	Mode mode,
	string ivStr,
	EncodingBase encodingBase
)
[VB.NET]
Public Shared Function Decrypt ( _
	inputStr As String, _
	keyStr As String, _
	mode As Mode, _
	ivStr As String, _
	encodingBase As EncodingBase _
) As String

Parameters

inputStr
Encoded input data
keyStr
Encoded key representing exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
ivStr
Encoded IV representing exactly 16 bytes or "" for ECB mode
encodingBase
Type: EncodingBase
Type of encoding used

Return Value

Decrypted data in encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (16 bytes)

Aes192.Dispose Method

Dispose of this object and clear any key schedules

Syntax

[C#]
public void Dispose()
[VB.NET]
Public Sub Dispose

Aes192.Encrypt Method (Byte[], Byte[], Mode, Byte[])

Encrypt data in byte array

Syntax

[C#]
public static byte[] Encrypt(
	byte[] input,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function Encrypt ( _
	input As Byte(), _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Byte()

Parameters

input
Input data
key
Key of exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Ciphertext in byte array or empty array on error

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (16 bytes)

Aes192.Encrypt Method (String, String, Mode, String)

Encrypt hex-encoded data string

Syntax

[C#]
public static string Encrypt(
	string inputHex,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function Encrypt ( _
	inputHex As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As String

Parameters

inputHex
Hex-encoded input data
keyHex
Hex-encoded key representing exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV representing exactly 16 bytes or "" for ECB mode

Return Value

Ciphertext in hex-encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (16 bytes)

Aes192.Encrypt Method (String, String, Mode, String, EncodingBase)

Encrypt encoded data string

Syntax

[C#]
public static string Encrypt(
	string inputStr,
	string keyStr,
	Mode mode,
	string ivStr,
	EncodingBase encodingBase
)
[VB.NET]
Public Shared Function Encrypt ( _
	inputStr As String, _
	keyStr As String, _
	mode As Mode, _
	ivStr As String, _
	encodingBase As EncodingBase _
) As String

Parameters

inputStr
Encoded input data
keyStr
Encoded key representing exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
ivStr
Encoded IV representing exactly 16 bytes or "" for ECB mode
encodingBase
Type: EncodingBase
Type of encoding used

Return Value

Ciphertext in encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (16 bytes)

Aes192.FileDecrypt Method (String, String, Byte[], Mode, Byte[])

Decrypt a file

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Aes192.FileDecrypt Method (String, String, Byte[], Mode, Byte[], CipherFileOption)

Decrypt a file with advanced options

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv,
	CipherFileOption advOptions
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte(), _
	advOptions As CipherFileOption _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes. Use null/Nothing for ECB mode or when using CipherFileOption.PrefixIV option
advOptions
Type: CipherFileOption
Advanced options. See CipherFileOption.

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Aes192.FileDecrypt Method (String, String, String, Mode, String)

Decrypt a file passing key and IV as hex strings

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
keyHex
Hex-encoded key of exact length
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV or "" for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same. The output file is in binary format.

Aes192.FileEncrypt Method (String, String, Byte[], Mode, Byte[])

Encrypt a file

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Aes192.FileEncrypt Method (String, String, Byte[], Mode, Byte[], CipherFileOption)

Encrypt a file with advanced options

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv,
	CipherFileOption advOptions
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte(), _
	advOptions As CipherFileOption _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode
advOptions
Type: CipherFileOption
Advanced options. See CipherFileOption.

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Aes192.FileEncrypt Method (String, String, String, Mode, String)

Encrypt a file passing key and IV as hex strings

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
keyHex
Hex-encoded key of exact length
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV or "" for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same. The output file is in binary format.

Aes192.InitDecrypt Method (Byte[], Mode, Byte[])

Initializes with key, mode and IV ready to start decrypting

Syntax

[C#]
public int InitDecrypt(
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Function InitDecrypt ( _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

key
Key of exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Aes192.InitDecrypt Method (String, Mode, String)

Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

[C#]
public int InitDecrypt(
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Function InitDecrypt ( _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

keyHex
Key in hex-encoded format
mode
Type: Mode
Cipher mode
ivHex
IV in hex-encoded format

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Aes192.InitEncrypt Method (Byte[], Mode, Byte[])

Initializes with key, mode and IV ready to start encrypting

Syntax

[C#]
public int InitEncrypt(
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Function InitEncrypt ( _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

key
Key of exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Aes192.InitEncrypt Method (String, Mode, String)

Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

[C#]
public int InitEncrypt(
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Function InitEncrypt ( _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

keyHex
Key in hex-encoded format
mode
Type: Mode
Cipher mode
ivHex
IV in hex-encoded format

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Aes192.Instance Method

Create the one and only instance

Syntax

[C#]
public static Aes192 Instance()
[VB.NET]
Public Shared Function Instance As Aes192

Return Value

Single instance to class

Remarks

CAUTION: Instances of Aes128, Aes192 and Aes256 are not independent in the same thread.

Aes192.Pad Method (Byte[])

Pads byte array to correct length for ECB and CBC encryption

Syntax

[C#]
public static byte[] Pad(
	byte[] data
)
[VB.NET]
Public Shared Function Pad ( _
	data As Byte() _
) As Byte()

Parameters

data
data to be padded

Return Value

padded data in byte array

Remarks

Uses PKCS#5/#7/CMS method of padding

Aes192.Pad Method (String)

Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

[C#]
public static string Pad(
	string dataHex
)
[VB.NET]
Public Shared Function Pad ( _
	dataHex As String _
) As String

Parameters

dataHex
hex-encoded data to be padded

Return Value

padded data in hex-encoded string

Remarks

Uses PKCS#5/#7/CMS method of padding

Aes192.Unpad Method (Byte[])

Removes the padding from an encryption block

Syntax

[C#]
public static byte[] Unpad(
	byte[] data
)
[VB.NET]
Public Shared Function Unpad ( _
	data As Byte() _
) As Byte()

Parameters

data
padded data

Return Value

Unpadded data in byte array or unchanged data on error

Remarks

Padding is expected according to the convention in PKCS#5/#7/CMS. An error is indicated by returning the original data which will always be longer than the expected unpadded result.

Aes192.Unpad Method (String)

Removes the padding from a hex-encoded encryption block

Syntax

[C#]
public static string Unpad(
	string dataHex
)
[VB.NET]
Public Shared Function Unpad ( _
	dataHex As String _
) As String

Parameters

dataHex
hex-encoded padded data

Return Value

Unpadded data in hex-encoded string or unchanged data on error

Remarks

Padding is expected according to the convention in PKCS#5/#7/CMS. An error is indicated by returning the original data which will always be longer than the expected unpadded result.

Aes192.Update Method (Byte[])

Transform byte input data with previously initialized key, mode and direction

Syntax

[C#]
public byte[] Update(
	byte[] data
)
[VB.NET]
Public Function Update ( _
	data As Byte() _
) As Byte()

Parameters

data
input data in byte array

Return Value

transformed data in byte array

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (16 bytes)

Aes192.Update Method (String)

Transform hex string data with previously initialized key, mode and direction

Syntax

[C#]
public string Update(
	string data
)
[VB.NET]
Public Function Update ( _
	data As String _
) As String

Parameters

data
hex-encoded input data

Return Value

hex-encoded data

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (16 bytes)

Aes256.Decrypt Method (Byte[], Byte[], Mode, Byte[])

Decrypt data in byte array

Syntax

[C#]
public static byte[] Decrypt(
	byte[] input,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function Decrypt ( _
	input As Byte(), _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Byte()

Parameters

input
Input data
key
Key of exactly 32 bytes (256 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Decrypted data in byte array or empty array on error

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (16 bytes)

Aes256.Decrypt Method (String, String, Mode, String)

Decrypt hex-encoded data string

Syntax

[C#]
public static string Decrypt(
	string inputHex,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function Decrypt ( _
	inputHex As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As String

Parameters

inputHex
Hex-encoded input data
keyHex
Hex-encoded key representing exactly 32 bytes (256 bits)
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV representing exactly 16 bytes or "" for ECB mode

Return Value

Decrypted data in hex-encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (16 bytes)

Aes256.Decrypt Method (String, String, Mode, String, EncodingBase)

Decrypt encoded data string

Syntax

[C#]
public static string Decrypt(
	string inputStr,
	string keyStr,
	Mode mode,
	string ivStr,
	EncodingBase encodingBase
)
[VB.NET]
Public Shared Function Decrypt ( _
	inputStr As String, _
	keyStr As String, _
	mode As Mode, _
	ivStr As String, _
	encodingBase As EncodingBase _
) As String

Parameters

inputStr
Encoded input data
keyStr
Encoded key representing exactly 32 bytes (256 bits)
mode
Type: Mode
Cipher Mode
ivStr
Encoded IV representing exactly 16 bytes or "" for ECB mode
encodingBase
Type: EncodingBase
Type of encoding used

Return Value

Decrypted data in encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (16 bytes)

Aes256.Dispose Method

Dispose of this object and clear any key schedules

Syntax

[C#]
public void Dispose()
[VB.NET]
Public Sub Dispose

Aes256.Encrypt Method (Byte[], Byte[], Mode, Byte[])

Encrypt data in byte array

Syntax

[C#]
public static byte[] Encrypt(
	byte[] input,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function Encrypt ( _
	input As Byte(), _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Byte()

Parameters

input
Input data
key
Key of exactly 32 bytes (256 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Ciphertext in byte array or empty array on error

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (16 bytes)

Aes256.Encrypt Method (String, String, Mode, String)

Encrypt hex-encoded data string

Syntax

[C#]
public static string Encrypt(
	string inputHex,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function Encrypt ( _
	inputHex As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As String

Parameters

inputHex
Hex-encoded input data
keyHex
Hex-encoded key representing exactly 32 bytes (256 bits)
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV representing exactly 16 bytes or "" for ECB mode

Return Value

Ciphertext in hex-encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (16 bytes)

Aes256.Encrypt Method (String, String, Mode, String, EncodingBase)

Encrypt encoded data string

Syntax

[C#]
public static string Encrypt(
	string inputStr,
	string keyStr,
	Mode mode,
	string ivStr,
	EncodingBase encodingBase
)
[VB.NET]
Public Shared Function Encrypt ( _
	inputStr As String, _
	keyStr As String, _
	mode As Mode, _
	ivStr As String, _
	encodingBase As EncodingBase _
) As String

Parameters

inputStr
Encoded input data
keyStr
Encoded key representing exactly 32 bytes (256 bits)
mode
Type: Mode
Cipher Mode
ivStr
Encoded IV representing exactly 16 bytes or "" for ECB mode
encodingBase
Type: EncodingBase
Type of encoding used

Return Value

Ciphertext in encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (16 bytes)

Aes256.FileDecrypt Method (String, String, Byte[], Mode, Byte[])

Decrypt a file

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 32 bytes (256 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Aes256.FileDecrypt Method (String, String, Byte[], Mode, Byte[], CipherFileOption)

Decrypt a file with advanced options

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv,
	CipherFileOption advOptions
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte(), _
	advOptions As CipherFileOption _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 32 bytes (256 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes. Use null/Nothing for ECB mode or when using CipherFileOption.PrefixIV option
advOptions
Type: CipherFileOption
Advanced options. See CipherFileOption.

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Aes256.FileDecrypt Method (String, String, String, Mode, String)

Decrypt a file passing key and IV as hex strings

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
keyHex
Hex-encoded key of exact length
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV or "" for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same. The output file is in binary format.

Aes256.FileEncrypt Method (String, String, Byte[], Mode, Byte[])

Encrypt a file

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 32 bytes (256 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Aes256.FileEncrypt Method (String, String, Byte[], Mode, Byte[], CipherFileOption)

Encrypt a file with advanced options

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv,
	CipherFileOption advOptions
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte(), _
	advOptions As CipherFileOption _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 32 bytes (256 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode
advOptions
Type: CipherFileOption
Advanced options. See CipherFileOption.

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Aes256.FileEncrypt Method (String, String, String, Mode, String)

Encrypt a file passing key and IV as hex strings

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
keyHex
Hex-encoded key of exact length
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV or "" for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same. The output file is in binary format.

Aes256.InitDecrypt Method (Byte[], Mode, Byte[])

Initializes with key, mode and IV ready to start decrypting

Syntax

[C#]
public int InitDecrypt(
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Function InitDecrypt ( _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

key
Key of exactly 32 bytes (256 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Aes256.InitDecrypt Method (String, Mode, String)

Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

[C#]
public int InitDecrypt(
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Function InitDecrypt ( _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

keyHex
Key in hex-encoded format
mode
Type: Mode
Cipher mode
ivHex
IV in hex-encoded format

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Aes256.InitEncrypt Method (Byte[], Mode, Byte[])

Initializes with key, mode and IV ready to start encrypting

Syntax

[C#]
public int InitEncrypt(
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Function InitEncrypt ( _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

key
Key of exactly 32 bytes (256 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Aes256.InitEncrypt Method (String, Mode, String)

Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

[C#]
public int InitEncrypt(
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Function InitEncrypt ( _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

keyHex
Key in hex-encoded format
mode
Type: Mode
Cipher mode
ivHex
IV in hex-encoded format

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Aes256.Instance Method

Create the one and only instance

Syntax

[C#]
public static Aes256 Instance()
[VB.NET]
Public Shared Function Instance As Aes256

Return Value

Single instance to class

Remarks

CAUTION: Instances of Aes128, Aes192 and Aes256 are not independent in the same thread.

Aes256.Pad Method (Byte[])

Pads byte array to correct length for ECB and CBC encryption

Syntax

[C#]
public static byte[] Pad(
	byte[] data
)
[VB.NET]
Public Shared Function Pad ( _
	data As Byte() _
) As Byte()

Parameters

data
data to be padded

Return Value

padded data in byte array

Remarks

Uses PKCS#5/#7/CMS method of padding

Aes256.Pad Method (String)

Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

[C#]
public static string Pad(
	string dataHex
)
[VB.NET]
Public Shared Function Pad ( _
	dataHex As String _
) As String

Parameters

dataHex
hex-encoded data to be padded

Return Value

padded data in hex-encoded string

Remarks

Uses PKCS#5/#7/CMS method of padding

Aes256.Unpad Method (Byte[])

Removes the padding from an encryption block

Syntax

[C#]
public static byte[] Unpad(
	byte[] data
)
[VB.NET]
Public Shared Function Unpad ( _
	data As Byte() _
) As Byte()

Parameters

data
padded data

Return Value

Unpadded data in byte array or unchanged data on error

Remarks

Padding is expected according to the convention in PKCS#5/#7/CMS. An error is indicated by returning the original data which will always be longer than the expected unpadded result.

Aes256.Unpad Method (String)

Removes the padding from a hex-encoded encryption block

Syntax

[C#]
public static string Unpad(
	string dataHex
)
[VB.NET]
Public Shared Function Unpad ( _
	dataHex As String _
) As String

Parameters

dataHex
hex-encoded padded data

Return Value

Unpadded data in hex-encoded string or unchanged data on error

Remarks

Padding is expected according to the convention in PKCS#5/#7/CMS. An error is indicated by returning the original data which will always be longer than the expected unpadded result.

Aes256.Update Method (Byte[])

Transform byte input data with previously initialized key, mode and direction

Syntax

[C#]
public byte[] Update(
	byte[] data
)
[VB.NET]
Public Function Update ( _
	data As Byte() _
) As Byte()

Parameters

data
input data in byte array

Return Value

transformed data in byte array

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (16 bytes)

Aes256.Update Method (String)

Transform hex string data with previously initialized key, mode and direction

Syntax

[C#]
public string Update(
	string data
)
[VB.NET]
Public Function Update ( _
	data As String _
) As String

Parameters

data
hex-encoded input data

Return Value

hex-encoded data

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (16 bytes)

Blowfish.Decrypt Method (Byte[], Byte[], Mode, Byte[])

Decrypt data in byte array

Syntax

[C#]
public static byte[] Decrypt(
	byte[] input,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function Decrypt ( _
	input As Byte(), _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Byte()

Parameters

input
Input data
key
Key of length between 1 and 56 bytes (448 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Decrypted data in byte array or empty array on error

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (8 bytes)

Blowfish.Decrypt Method (String, String, Mode, String)

Decrypt hex-encoded data string

Syntax

[C#]
public static string Decrypt(
	string inputHex,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function Decrypt ( _
	inputHex As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As String

Parameters

inputHex
Hex-encoded input data
keyHex
Hex-encoded key
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV representing exactly 8 bytes or "" for ECB mode

Return Value

Decrypted data in hex-encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (8 bytes)

Blowfish.Decrypt Method (String, String, Mode, String, EncodingBase)

Decrypt encoded data string

Syntax

[C#]
public static string Decrypt(
	string inputStr,
	string keyStr,
	Mode mode,
	string ivStr,
	EncodingBase encodingBase
)
[VB.NET]
Public Shared Function Decrypt ( _
	inputStr As String, _
	keyStr As String, _
	mode As Mode, _
	ivStr As String, _
	encodingBase As EncodingBase _
) As String

Parameters

inputStr
Encoded input data
keyStr
Encoded key
mode
Type: Mode
Cipher Mode
ivStr
Encoded IV representing exactly 8 bytes or "" for ECB mode
encodingBase
Type: EncodingBase
Type of encoding used

Return Value

Decrypted data in encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (8 bytes)

Blowfish.Dispose Method

Dispose of this object and clear any key schedules

Syntax

[C#]
public void Dispose()
[VB.NET]
Public Sub Dispose

Blowfish.Encrypt Method (Byte[], Byte[], Mode, Byte[])

Encrypt data in byte array

Syntax

[C#]
public static byte[] Encrypt(
	byte[] input,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function Encrypt ( _
	input As Byte(), _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Byte()

Parameters

input
Input data
key
Key of length between 1 and 56 bytes (448 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Ciphertext in byte array or empty array on error

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (8 bytes)

Blowfish.Encrypt Method (String, String, Mode, String)

Encrypt hex-encoded data string

Syntax

[C#]
public static string Encrypt(
	string inputHex,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function Encrypt ( _
	inputHex As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As String

Parameters

inputHex
Hex-encoded input data
keyHex
Hex-encoded key
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV representing exactly 8 bytes or "" for ECB mode

Return Value

Ciphertext in hex-encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (8 bytes)

Blowfish.Encrypt Method (String, String, Mode, String, EncodingBase)

Encrypt encoded data string

Syntax

[C#]
public static string Encrypt(
	string inputStr,
	string keyStr,
	Mode mode,
	string ivStr,
	EncodingBase encodingBase
)
[VB.NET]
Public Shared Function Encrypt ( _
	inputStr As String, _
	keyStr As String, _
	mode As Mode, _
	ivStr As String, _
	encodingBase As EncodingBase _
) As String

Parameters

inputStr
Encoded input data
keyStr
Encoded key
mode
Type: Mode
Cipher Mode
ivStr
Encoded IV representing exactly 8 bytes or "" for ECB mode
encodingBase
Type: EncodingBase
Type of encoding used

Return Value

Ciphertext in encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (8 bytes)

Blowfish.FileDecrypt Method (String, String, Byte[], Mode, Byte[])

Decrypt a file

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of length between 1 and 56 bytes (448 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Blowfish.FileDecrypt Method (String, String, Byte[], Mode, Byte[], CipherFileOption)

Decrypt a file with advanced options

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv,
	CipherFileOption advOptions
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte(), _
	advOptions As CipherFileOption _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of length between 1 and 56 bytes (448 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes. Use null/Nothing for ECB mode or when using CipherFileOption.PrefixIV option
advOptions
Type: CipherFileOption
Advanced options. See CipherFileOption.

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Blowfish.FileDecrypt Method (String, String, String, Mode, String)

Decrypt a file passing key and IV as hex strings

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
keyHex
Hex-encoded key
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV or "" for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same. The output file is in binary format.

Blowfish.FileEncrypt Method (String, String, Byte[], Mode, Byte[])

Encrypt a file

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of length between 1 and 56 bytes (448 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Blowfish.FileEncrypt Method (String, String, Byte[], Mode, Byte[], CipherFileOption)

Encrypt a file with advanced options

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv,
	CipherFileOption advOptions
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte(), _
	advOptions As CipherFileOption _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of length between 1 and 56 bytes (448 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode
advOptions
Type: CipherFileOption
Advanced options. See CipherFileOption.

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Blowfish.FileEncrypt Method (String, String, String, Mode, String)

Encrypt a file passing key and IV as hex strings

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
keyHex
Hex-encoded key
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV or "" for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same. The output file is in binary format.

Blowfish.InitDecrypt Method (Byte[], Mode, Byte[])

Initializes with key, mode and IV ready to start decrypting

Syntax

[C#]
public int InitDecrypt(
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Function InitDecrypt ( _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

key
Key of length between 1 and 56 bytes (448 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Blowfish.InitDecrypt Method (String, Mode, String)

Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

[C#]
public int InitDecrypt(
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Function InitDecrypt ( _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

keyHex
Key in hex-encoded format
mode
Type: Mode
Cipher mode
ivHex
IV in hex-encoded format

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Blowfish.InitEncrypt Method (Byte[], Mode, Byte[])

Initializes with key, mode and IV ready to start encrypting

Syntax

[C#]
public int InitEncrypt(
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Function InitEncrypt ( _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

key
Key of length between 1 and 56 bytes (448 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Blowfish.InitEncrypt Method (String, Mode, String)

Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

[C#]
public int InitEncrypt(
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Function InitEncrypt ( _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

keyHex
Key in hex-encoded format
mode
Type: Mode
Cipher mode
ivHex
IV in hex-encoded format

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Blowfish.Instance Method

Create the one and only instance

Syntax

[C#]
public static Blowfish Instance()
[VB.NET]
Public Shared Function Instance As Blowfish

Return Value

Single instance to class

Blowfish.Pad Method (Byte[])

Pads byte array to correct length for ECB and CBC encryption

Syntax

[C#]
public static byte[] Pad(
	byte[] data
)
[VB.NET]
Public Shared Function Pad ( _
	data As Byte() _
) As Byte()

Parameters

data
data to be padded

Return Value

padded data in byte array

Remarks

Uses PKCS#5/#7/CMS method of padding

Blowfish.Pad Method (String)

Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

[C#]
public static string Pad(
	string dataHex
)
[VB.NET]
Public Shared Function Pad ( _
	dataHex As String _
) As String

Parameters

dataHex
hex-encoded data to be padded

Return Value

padded data in hex-encoded string

Remarks

Uses PKCS#5/#7/CMS method of padding

Blowfish.Unpad Method (Byte[])

Removes the padding from an encryption block

Syntax

[C#]
public static byte[] Unpad(
	byte[] data
)
[VB.NET]
Public Shared Function Unpad ( _
	data As Byte() _
) As Byte()

Parameters

data
padded data

Return Value

Unpadded data in byte array or unchanged data on error

Remarks

Padding is expected according to the convention in PKCS#5/#7/CMS. An error is indicated by returning the original data which will always be longer than the expected unpadded result.

Blowfish.Unpad Method (String)

Removes the padding from a hex-encoded encryption block

Syntax

[C#]
public static string Unpad(
	string dataHex
)
[VB.NET]
Public Shared Function Unpad ( _
	dataHex As String _
) As String

Parameters

dataHex
hex-encoded padded data

Return Value

Unpadded data in hex-encoded string or unchanged data on error

Remarks

Padding is expected according to the convention in PKCS#5/#7/CMS. An error is indicated by returning the original data which will always be longer than the expected unpadded result.

Blowfish.Update Method (Byte[])

Transform byte input data with previously initialized key, mode and direction

Syntax

[C#]
public byte[] Update(
	byte[] data
)
[VB.NET]
Public Function Update ( _
	data As Byte() _
) As Byte()

Parameters

data
input data in byte array

Return Value

transformed data in byte array

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (8 bytes)

Blowfish.Update Method (String)

Transform hex string data with previously initialized key, mode and direction

Syntax

[C#]
public string Update(
	string data
)
[VB.NET]
Public Function Update ( _
	data As String _
) As String

Parameters

data
hex-encoded input data

Return Value

hex-encoded data

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (8 bytes)

Cipher.BlockBytes Method

Return the block size in bytes for a given cipher algorithm

Syntax

[C#]
public static int BlockBytes(
	CipherAlgorithm alg
)
[VB.NET]
Public Shared Function BlockBytes ( _
	alg As CipherAlgorithm _
) As Integer

Parameters

alg
Type: CipherAlgorithm
Cipher algorithm

Return Value

Block size in bytes

Cipher.Decrypt Method (Byte[], Byte[], Byte[], CipherAlgorithm, Mode, Padding, Cipher.Opts)

Decrypt data in a byte array using the specified block cipher algorithm, mode and padding.

Syntax

[C#]
public static byte[] Decrypt(
	byte[] input,
	byte[] key,
	byte[] iv,
	CipherAlgorithm cipherAlg,
	Mode mode,
	Padding pad,
	Cipher.Opts opts
)
[VB.NET]
Public Shared Function Decrypt ( _
	input As Byte(), _
	key As Byte(), _
	iv As Byte(), _
	cipherAlg As CipherAlgorithm, _
	mode As Mode, _
	pad As Padding, _
	opts As Cipher.Opts _
) As Byte()

Parameters

input
Input data to be decrypted
key
Key of exact length for block cipher algorithm
iv
Initialization Vector (IV) of exactly the block size or null for ECB mode, if not provided in input.
cipherAlg
Type: CipherAlgorithm
Cipher algorithm
mode
Type: Mode
Cipher mode
pad
Type: Padding
Padding method to use
opts
Type: Cipher.Opts
Advanced options (optional). Use Cipher.Opts.PrefixIV to expect the IV to be prepended at the start of the input.

Return Value

Decrypted plaintext in byte array or empty array on error

Remarks

Default padding is Pkcs5 for ECB and CBC mode and NoPad for all other modes. It is an error if the specified padding is not found after decryption.

Cipher.Decrypt Method (String, String, String, CipherAlgorithm, Mode, Padding, Cipher.Opts)

Decrypt hex-encoded data using specified block cipher algorithm, mode and padding.

Syntax

[C#]
public static string Decrypt(
	string inputHex,
	string keyHex,
	string ivHex,
	CipherAlgorithm cipherAlg,
	Mode mode,
	Padding pad,
	Cipher.Opts opts
)
[VB.NET]
Public Shared Function Decrypt ( _
	inputHex As String, _
	keyHex As String, _
	ivHex As String, _
	cipherAlg As CipherAlgorithm, _
	mode As Mode, _
	pad As Padding, _
	opts As Cipher.Opts _
) As String

Parameters

inputHex
Hex-encoded input data
keyHex
Hex-encoded key representing exact key length
ivHex
Hex-encoded IV representing exact block length or "" for ECB mode
cipherAlg
Type: CipherAlgorithm
Cipher Algorithm
mode
Type: Mode
Cipher Mode
pad
Type: Padding
Padding method to use
opts
Type: Cipher.Opts
Advanced options (optional). Use Cipher.Opts.PrefixIV to prepend the IV to the output.

Return Value

Decrypted plaintex in hex-encoded string or empty string on error

Remarks

Input data may be any even number of hex characters, but not zero. Default padding is Pkcs5 for ECB and CBC mode and NoPad for all other modes.

Cipher.Dispose Method

Dispose of this object and clear any stored data.

Syntax

[C#]
public void Dispose()
[VB.NET]
Public Sub Dispose

Cipher.Encrypt Method (Byte[], Byte[], Byte[], CipherAlgorithm, Mode, Padding, Cipher.Opts)

Encrypt data in a byte array using the specified block cipher algorithm, mode and padding.

Syntax

[C#]
public static byte[] Encrypt(
	byte[] input,
	byte[] key,
	byte[] iv,
	CipherAlgorithm cipherAlg,
	Mode mode,
	Padding pad,
	Cipher.Opts opts
)
[VB.NET]
Public Shared Function Encrypt ( _
	input As Byte(), _
	key As Byte(), _
	iv As Byte(), _
	cipherAlg As CipherAlgorithm, _
	mode As Mode, _
	pad As Padding, _
	opts As Cipher.Opts _
) As Byte()

Parameters

input
Input data to be encrypted
key
Key of exact length for block cipher algorithm
iv
Initialization Vector (IV) of exactly the block size or null for ECB mode, if not provided in input.
cipherAlg
Type: CipherAlgorithm
Cipher algorithm
mode
Type: Mode
Cipher mode
pad
Type: Padding
Padding method to use
opts
Type: Cipher.Opts
Advanced options (optional). Use Cipher.Opts.PrefixIV to prepend the IV to the output.

Return Value

Ciphertext in byte array or empty array on error

Remarks

Default padding is Pkcs5 for ECB and CBC mode and NoPad for all other modes.

Cipher.Encrypt Method (String, String, String, CipherAlgorithm, Mode, Padding, Cipher.Opts)

Encrypt hex-encoded data using specified block cipher algorithm, mode and padding.

Syntax

[C#]
public static string Encrypt(
	string inputHex,
	string keyHex,
	string ivHex,
	CipherAlgorithm cipherAlg,
	Mode mode,
	Padding pad,
	Cipher.Opts opts
)
[VB.NET]
Public Shared Function Encrypt ( _
	inputHex As String, _
	keyHex As String, _
	ivHex As String, _
	cipherAlg As CipherAlgorithm, _
	mode As Mode, _
	pad As Padding, _
	opts As Cipher.Opts _
) As String

Parameters

inputHex
Hex-encoded input data
keyHex
Hex-encoded key representing exact key length
ivHex
Hex-encoded IV representing exact block length or "" for ECB mode
cipherAlg
Type: CipherAlgorithm
Cipher Algorithm
mode
Type: Mode
Cipher Mode
pad
Type: Padding
Padding method to use
opts
Type: Cipher.Opts
Advanced options (optional). Use Cipher.Opts.PrefixIV to prepend the IV to the output.

Return Value

Encrypted ciphertext in hex-encoded string or empty string on error

Remarks

Input data may be any even number of hex characters, but not zero. Default padding is Pkcs5 for ECB and CBC mode and NoPad for all other modes.

Cipher.FileDecrypt Method

Decrypt a file with block cipher

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	byte[] iv,
	CipherAlgorithm cipherAlg,
	Mode mode,
	Padding pad,
	Cipher.Opts opts
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	iv As Byte(), _
	cipherAlg As CipherAlgorithm, _
	mode As Mode, _
	pad As Padding, _
	opts As Cipher.Opts _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of of exact length for block cipher algorithm
iv
Initialization Vector (IV) of exactly the block size or null for ECB mode
cipherAlg
Type: CipherAlgorithm
Cipher Algorithm
mode
Type: Mode
Cipher Mode
pad
Type: Padding
Padding method to use (ECB and CBC modes only)
opts
Type: Cipher.Opts
Advanced options

Return Value

0 if successful or nonzero error code

Remarks

fileOut and fileIn must not be the same

Cipher.FileEncrypt Method

Encrypt a file with block cipher

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	byte[] iv,
	CipherAlgorithm cipherAlg,
	Mode mode,
	Padding pad,
	Cipher.Opts opts
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	iv As Byte(), _
	cipherAlg As CipherAlgorithm, _
	mode As Mode, _
	pad As Padding, _
	opts As Cipher.Opts _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of of exact length for block cipher algorithm
iv
Initialization Vector (IV) of exactly the block size or null for ECB mode
cipherAlg
Type: CipherAlgorithm
Cipher Algorithm
mode
Type: Mode
Cipher Mode
pad
Type: Padding
Padding method to use (ECB and CBC modes only)
opts
Type: Cipher.Opts
Advanced options

Return Value

0 if successful or nonzero error code

Remarks

fileOut and fileIn must not be the same

Cipher.InitDecrypt Method (Byte[], Byte[], CipherAlgorithm, Mode)

Initializes with key, iv, algorithm and mode ready to start decrypting with repeated update operations.

Syntax

[C#]
public bool InitDecrypt(
	byte[] key,
	byte[] iv,
	CipherAlgorithm cipherAlg,
	Mode mode
)
[VB.NET]
Public Function InitDecrypt ( _
	key As Byte(), _
	iv As Byte(), _
	cipherAlg As CipherAlgorithm, _
	mode As Mode _
) As Boolean

Parameters

key
Key of exact length for block cipher algorithm.
iv
Initialization Vector (IV) of exactly the block size or null/Nothing for ECB mode.
cipherAlg
Type: CipherAlgorithm
Cipher algorithm
mode
Type: Mode
Cipher mode

Return Value

True if successful, False if failed.

Cipher.InitDecrypt Method (String, String, CipherAlgorithm, Mode)

Initializes with hex-encoded key, iv, algorithm and mode ready to start decrypting with repeated update operations.

Syntax

[C#]
public bool InitDecrypt(
	string keyHex,
	string ivHex,
	CipherAlgorithm cipherAlg,
	Mode mode
)
[VB.NET]
Public Function InitDecrypt ( _
	keyHex As String, _
	ivHex As String, _
	cipherAlg As CipherAlgorithm, _
	mode As Mode _
) As Boolean

Parameters

keyHex
Hex-encoded key of exact length for block cipher algorithm.
ivHex
Hex-encoded Initialization Vector (IV) of exactly the block size or "" for ECB mode.
cipherAlg
Type: CipherAlgorithm
Cipher algorithm
mode
Type: Mode
Cipher mode

Return Value

True if successful, False if failed.

Cipher.InitEncrypt Method (Byte[], Byte[], CipherAlgorithm, Mode)

Initializes with key, iv, algorithm and mode ready to start encrypting with repeated update operations.

Syntax

[C#]
public bool InitEncrypt(
	byte[] key,
	byte[] iv,
	CipherAlgorithm cipherAlg,
	Mode mode
)
[VB.NET]
Public Function InitEncrypt ( _
	key As Byte(), _
	iv As Byte(), _
	cipherAlg As CipherAlgorithm, _
	mode As Mode _
) As Boolean

Parameters

key
Key of exact length for block cipher algorithm.
iv
Initialization Vector (IV) of exactly the block size or null/Nothing for ECB mode.
cipherAlg
Type: CipherAlgorithm
Cipher algorithm
mode
Type: Mode
Cipher mode

Return Value

True if successful, False if failed.

Cipher.InitEncrypt Method (String, String, CipherAlgorithm, Mode)

Initializes with hex-encoded key, iv, algorithm and mode ready to start encrypting with repeated update operations.

Syntax

[C#]
public bool InitEncrypt(
	string keyHex,
	string ivHex,
	CipherAlgorithm cipherAlg,
	Mode mode
)
[VB.NET]
Public Function InitEncrypt ( _
	keyHex As String, _
	ivHex As String, _
	cipherAlg As CipherAlgorithm, _
	mode As Mode _
) As Boolean

Parameters

keyHex
Hex-encoded key of exact length for block cipher algorithm.
ivHex
Hex-encoded Initialization Vector (IV) of exactly the block size or "" for ECB mode.
cipherAlg
Type: CipherAlgorithm
Cipher algorithm
mode
Type: Mode
Cipher mode

Return Value

True if successful, False if failed.

Cipher.Instance Method

Create the one and only instance

Syntax

[C#]
public static Cipher Instance()
[VB.NET]
Public Shared Function Instance As Cipher

Return Value

Single instance to class

Cipher.KeyBytes Method

Return the key size in bytes for a given cipher algorithm

Syntax

[C#]
public static int KeyBytes(
	CipherAlgorithm alg
)
[VB.NET]
Public Shared Function KeyBytes ( _
	alg As CipherAlgorithm _
) As Integer

Parameters

alg
Type: CipherAlgorithm
Cipher algorithm

Return Value

Key size in bytes

Cipher.KeyUnwrap Method

Unwraps (decrypts) key material with a key-encryption key

Syntax

[C#]
public static byte[] KeyUnwrap(
	byte[] data,
	byte[] kek,
	CipherAlgorithm cipherAlg
)
[VB.NET]
Public Shared Function KeyUnwrap ( _
	data As Byte(), _
	kek As Byte(), _
	cipherAlg As CipherAlgorithm _
) As Byte()

Parameters

data
Wrapped key
kek
Key encryption key
cipherAlg
Type: CipherAlgorithm
Block cipher to use for wrapping

Return Value

Unwrapped key material (or empty array on error)

Cipher.KeyWrap Method

Wraps (encrypts) key material with a key-encryption key

Syntax

[C#]
public static byte[] KeyWrap(
	byte[] data,
	byte[] kek,
	CipherAlgorithm cipherAlg
)
[VB.NET]
Public Shared Function KeyWrap ( _
	data As Byte(), _
	kek As Byte(), _
	cipherAlg As CipherAlgorithm _
) As Byte()

Parameters

data
Key material to be wrapped
kek
Key encryption key
cipherAlg
Type: CipherAlgorithm
Block cipher to use for wrapping

Return Value

Wrapped key (or empty array on error)

Cipher.Pad Method (Byte[], CipherAlgorithm, Padding)

Pad byte array for block cipher.

Syntax

[C#]
public static byte[] Pad(
	byte[] input,
	CipherAlgorithm cipherAlg,
	Padding pad
)
[VB.NET]
Public Shared Function Pad ( _
	input As Byte(), _
	cipherAlg As CipherAlgorithm, _
	pad As Padding _
) As Byte()

Parameters

input
data to be padded
cipherAlg
Type: CipherAlgorithm
Block cipher being used
pad
Type: Padding
Padding method to use

Return Value

Padded data in byte array

Cipher.Pad Method (String, CipherAlgorithm, Padding)

Pads hex-encoded string for block cipher.

Syntax

[C#]
public static string Pad(
	string inputHex,
	CipherAlgorithm cipherAlg,
	Padding pad
)
[VB.NET]
Public Shared Function Pad ( _
	inputHex As String, _
	cipherAlg As CipherAlgorithm, _
	pad As Padding _
) As String

Parameters

inputHex
hex-encoded data to be padded
cipherAlg
Type: CipherAlgorithm
Block cipher being used
pad
Type: Padding
Padding method to use

Return Value

Padded data in hex-encoded string

Cipher.Unpad Method (Byte[], CipherAlgorithm, Padding)

Remove padding from an encryption block.

Syntax

[C#]
public static byte[] Unpad(
	byte[] input,
	CipherAlgorithm cipherAlg,
	Padding pad
)
[VB.NET]
Public Shared Function Unpad ( _
	input As Byte(), _
	cipherAlg As CipherAlgorithm, _
	pad As Padding _
) As Byte()

Parameters

input
padded data
cipherAlg
Type: CipherAlgorithm
Block cipher being used
pad
Type: Padding
Padding method to use

Return Value

Unpadded data in byte array.

Remarks

Unless pad is NoPad, the unpadded output is always shorter than the padded input. An error is indicated by returning the original data.

Cipher.Unpad Method (String, CipherAlgorithm, Padding)

Remove padding from a hex-encoded encryption block.

Syntax

[C#]
public static string Unpad(
	string inputHex,
	CipherAlgorithm cipherAlg,
	Padding pad
)
[VB.NET]
Public Shared Function Unpad ( _
	inputHex As String, _
	cipherAlg As CipherAlgorithm, _
	pad As Padding _
) As String

Parameters

inputHex
hex-encoded padded data
cipherAlg
Type: CipherAlgorithm
Block cipher being used
pad
Type: Padding
Padding method to use

Return Value

Unpadded data in hex-encoded string.

Remarks

Unless pad is NoPad, the unpadded output is always shorter than the padded input. An error is indicated by returning the original data.

Cipher.Update Method (Byte[])

Transform byte input data with previously initialized key, mode and direction.

Syntax

[C#]
public byte[] Update(
	byte[] data
)
[VB.NET]
Public Function Update ( _
	data As Byte() _
) As Byte()

Parameters

data
Input data in byte array.

Return Value

Transformed data in byte array.

Cipher.Update Method (String)

Transform hex string data with previously initialized key, mode and direction

Syntax

[C#]
public string Update(
	string dataHex
)
[VB.NET]
Public Function Update ( _
	dataHex As String _
) As String

Parameters

dataHex
Hex-encoded input data

Return Value

Hex-encoded data

Remarks

For all modes, the length of the decoded input bytes must be an exact multiple of the cipher block length (8 or 16 bytes).

CipherStream.Bytes Method

Enciphers data in array of bytes using specified stream cipher.

Syntax

[C#]
public static byte[] Bytes(
	byte[] input,
	byte[] key,
	byte[] iv,
	int counter,
	CipherStream.Algorithm streamAlg
)
[VB.NET]
Public Shared Function Bytes ( _
	input As Byte(), _
	key As Byte(), _
	iv As Byte(), _
	counter As Integer, _
	streamAlg As CipherStream.Algorithm _
) As Byte()

Parameters

input
Input data to be encrypted
key
Key
iv
Initialization Vector (IV, nonce) or null for Arcfour
counter
Counter value for ChaCha20 only, otherwise ignored. Use 0 for default.
streamAlg
Type: CipherStream.Algorithm
Stream cipher algorithm

Return Value

Ciphertext in byte array, or empty array on error

Remarks


CipherStream.Dispose Method

Dispose of this object and clear any key schedules

Syntax

[C#]
public void Dispose()
[VB.NET]
Public Sub Dispose

CipherStream.File Method

Enciphers data in a file using specified stream cipher.

Syntax

[C#]
public static int File(
	string fileOut,
	string fileIn,
	byte[] key,
	byte[] iv,
	int counter,
	CipherStream.Algorithm streamAlg
)
[VB.NET]
Public Shared Function File ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	iv As Byte(), _
	counter As Integer, _
	streamAlg As CipherStream.Algorithm _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key
iv
Initialization Vector (IV, nonce) or null for Arcfour
counter
Counter value for ChaCha20 only, otherwise ignored. Use 0 for default.
streamAlg
Type: CipherStream.Algorithm
Stream cipher algorithm

Return Value

0 if successful or nonzero error code

Remarks

fileOut and fileIn must not be the same

CipherStream.Hex Method

Enciphers data in a hex-encoded string using specified stream cipher.

Syntax

[C#]
public static string Hex(
	string inputHex,
	string keyHex,
	string ivHex,
	int counter,
	CipherStream.Algorithm streamAlg
)
[VB.NET]
Public Shared Function Hex ( _
	inputHex As String, _
	keyHex As String, _
	ivHex As String, _
	counter As Integer, _
	streamAlg As CipherStream.Algorithm _
) As String

Parameters

inputHex
Hex-encoded input data
keyHex
Hex-encoded key
ivHex
Hex-encoded Initialization Vector (IV, nonce) or "" for Arcfour
counter
Counter value for ChaCha20 only, otherwise ignored. Use 0 for default.
streamAlg
Type: CipherStream.Algorithm
Stream cipher algorithm

Return Value

Ciphertext in hex-encoded string or empty string on error

Remarks


CipherStream.Init Method

Initializes the context ready for repeated operations of CipherStream.Update

Syntax

[C#]
public int Init(
	byte[] key,
	byte[] iv,
	int counter,
	CipherStream.Algorithm streamAlg
)
[VB.NET]
Public Function Init ( _
	key As Byte(), _
	iv As Byte(), _
	counter As Integer, _
	streamAlg As CipherStream.Algorithm _
) As Integer

Parameters

key
Key
iv
Initialization Vector (IV, nonce) or null for Arcfour
counter
Counter value for ChaCha20 only, otherwise ignored. Use 0 for default.
streamAlg
Type: CipherStream.Algorithm
Stream cipher algorithm

Return Value

0 if successful or nonzero error code

Remarks


CipherStream.Instance Method

Create the one and only instance

Syntax

[C#]
public static CipherStream Instance()
[VB.NET]
Public Shared Function Instance As CipherStream

Return Value

Single instance to class

Remarks

CAUTION: Instances of different algorithms are not independent in the same thread.

CipherStream.Update Method

Encrypts input using current context

Syntax

[C#]
public byte[] Update(
	byte[] input
)
[VB.NET]
Public Function Update ( _
	input As Byte() _
) As Byte()

Parameters

input
Input data to be encrypted

Return Value

Encrypted data in array of exactly the same length as input; or an empty array on error

Remarks

Check CipherStream.ErrCode for error details

Cnv.Base64Filter Method

Filters non-base64 characters from a string

Syntax

[C#]
public static string Base64Filter(
	string s
)
[VB.NET]
Public Shared Function Base64Filter ( _
	s As String _
) As String

Parameters

s
String to be filtered

Return Value

Filtered string

Remarks

Valid base64 characters are [0-9A-Za-z+/=]

Cnv.Base64FromHex Method

Converts hexadecimal-encoded data into base64-encoded data

Syntax

[C#]
public static string Base64FromHex(
	string s
)
[VB.NET]
Public Shared Function Base64FromHex ( _
	s As String _
) As String

Parameters

s
Hex-encoded data

Return Value

Base64-encoded data

Cnv.FromBase64 Method

Converts a base64-encoded string to an equivalent array of 8-bit unsigned integers.

Syntax

[C#]
public static byte[] FromBase64(
	string s
)
[VB.NET]
Public Shared Function FromBase64 ( _
	s As String _
) As Byte()

Parameters

s
Base64-encoded data

Return Value

Data as array of bytes

Cnv.FromHex Method

Converts a hexadecimal-encoded string to an equivalent array of 8-bit unsigned integers.

Syntax

[C#]
public static byte[] FromHex(
	string s
)
[VB.NET]
Public Shared Function FromHex ( _
	s As String _
) As Byte()

Parameters

s
Hex-encoded data

Return Value

Data as array of bytes

Cnv.HexFilter Method

Filters non-hexadecimal characters from a string

Syntax

[C#]
public static string HexFilter(
	string s
)
[VB.NET]
Public Shared Function HexFilter ( _
	s As String _
) As String

Parameters

s
String to be filtered

Return Value

Filtered string

Remarks

Valid hex characters are [0-9A-Fa-f]

Cnv.HexFromBase64 Method

Converts base64-encoded data into hexadecimal-encoded data

Syntax

[C#]
public static string HexFromBase64(
	string s
)
[VB.NET]
Public Shared Function HexFromBase64 ( _
	s As String _
) As String

Parameters

s
Base64-encoded data

Return Value

Hex-encoded data

Cnv.ShortPathName Method

Retrieve the Windows short path form of the specified path.

Syntax

[C#]
public static string ShortPathName(
	string pathName
)
[VB.NET]
Public Shared Function ShortPathName ( _
	pathName As String _
) As String

Parameters

pathName
File path name.

Return Value

Windows short path name of file or the empty string if file does not exist.

Remarks

Windows platforms only. The file path must exist. The short path name is guaranteed to be ASCII.

Cnv.StringFromBase64 Method

Converts a base64-encoded string into a text string

Syntax

[C#]
public static string StringFromBase64(
	string s
)
[VB.NET]
Public Shared Function StringFromBase64 ( _
	s As String _
) As String

Parameters

s
Base64-encoded data

Return Value

String value

Remarks

Uses the 'Default' encoding for the system's current ANSI code page

Cnv.StringFromHex Method

Converts a hexadecimal-encoded string into a text string

Syntax

[C#]
public static string StringFromHex(
	string s
)
[VB.NET]
Public Shared Function StringFromHex ( _
	s As String _
) As String

Parameters

s
Hex-encoded data

Return Value

String value

Remarks

Uses the 'Default' encoding for the system's current ANSI code page

Cnv.ToBase64 Method (Byte[])

Converts 8-bit binary data to equivalent base64-encoded string format

Syntax

[C#]
public static string ToBase64(
	byte[] binaryData
)
[VB.NET]
Public Shared Function ToBase64 ( _
	binaryData As Byte() _
) As String

Parameters

binaryData
binary data

Return Value

Base64-encoded string

Cnv.ToBase64 Method (String)

Converts a string of ANSI characters to equivalent base64-encoded string format

Syntax

[C#]
public static string ToBase64(
	string s
)
[VB.NET]
Public Shared Function ToBase64 ( _
	s As String _
) As String

Parameters

s
String of data to be encoded

Return Value

Base64-encoded data

Remarks

Uses the 'Default' encoding for the system's current ANSI code page

Cnv.ToHex Method (Byte[])

Converts 8-bit binary data to equivalent hexadecimal string format

Syntax

[C#]
public static string ToHex(
	byte[] binaryData
)
[VB.NET]
Public Shared Function ToHex ( _
	binaryData As Byte() _
) As String

Parameters

binaryData
binary data

Return Value

Hex-encoded string

Cnv.ToHex Method (String)

Converts a string of ANSI characters to equivalent hexadecimal string format

Syntax

[C#]
public static string ToHex(
	string s
)
[VB.NET]
Public Shared Function ToHex ( _
	s As String _
) As String

Parameters

s
String of data to be encoded

Return Value

Hex-encoded data

Remarks

Uses the 'Default' encoding for the system's current ANSI code page

Compr.Compress Method

Compress data using compression algorithm.

Syntax

[C#]
public static byte[] Compress(
	byte[] data,
	ComprAlgorithm comprAlg
)
[VB.NET]
Public Shared Function Compress ( _
	data As Byte(), _
	comprAlg As ComprAlgorithm _
) As Byte()

Parameters

data
Data to be compressed.
comprAlg
Type: ComprAlgorithm
Compression algorithm.

Return Value

Compressed data, or an empty array on error.

Compr.Uncompress Method

Uncompress data using compression algorithm.

Syntax

[C#]
public static byte[] Uncompress(
	byte[] data,
	ComprAlgorithm comprAlg
)
[VB.NET]
Public Shared Function Uncompress ( _
	data As Byte(), _
	comprAlg As ComprAlgorithm _
) As Byte()

Parameters

data
Compressed data to be uncompressed.
comprAlg
Type: ComprAlgorithm
Compression algorithm.

Return Value

Uncompressed data, or an empty array on error.

Remarks

An empty array may also be returned in the trivial case that the original data was the empty array itself.

Crc.Data Method (Byte[])

Computes CRC-32 checksum for data

Syntax

[C#]
public static int Data(
	byte[] data
)
[VB.NET]
Public Shared Function Data ( _
	data As Byte() _
) As Integer

Parameters

data
input data

Return Value

Value of CRC-32 checksum

Crc.Data Method (String)

Computes CRC-32 checksum for a string

Syntax

[C#]
public static int Data(
	string Str
)
[VB.NET]
Public Shared Function Data ( _
	Str As String _
) As Integer

Parameters

Str
input data

Return Value

Value of CRC-32 checksum

Crc.File Method

Computes CRC-32 checksum for a file

Syntax

[C#]
public static int File(
	string fileName
)
[VB.NET]
Public Shared Function File ( _
	fileName As String _
) As Integer

Parameters

fileName
Name of input file

Return Value

Value of CRC-32 checksum

Remarks

If return value is zero, the file could not be found or read

Des.CheckKey Method (Byte[])

Verifies that no part of the key is a weak or semi-weak DES key.

Syntax

[C#]
public static int CheckKey(
	byte[] key
)
[VB.NET]
Public Shared Function CheckKey ( _
	key As Byte() _
) As Integer

Parameters

key
Key to check

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Des.CheckKey Method (String)

Verifies that no part of the key is a weak or semi-weak DES key.

Syntax

[C#]
public static int CheckKey(
	string keyHex
)
[VB.NET]
Public Shared Function CheckKey ( _
	keyHex As String _
) As Integer

Parameters

keyHex
Hex-encoded key to check

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Des.Decrypt Method (Byte[], Byte[], Mode, Byte[])

Decrypt data in byte array

Syntax

[C#]
public static byte[] Decrypt(
	byte[] input,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function Decrypt ( _
	input As Byte(), _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Byte()

Parameters

input
Input data
key
Key of exactly 8 bytes (64 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Decrypted data in byte array or empty array on error

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (8 bytes)

Des.Decrypt Method (String, String, Mode, String)

Decrypt hex-encoded data string

Syntax

[C#]
public static string Decrypt(
	string inputHex,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function Decrypt ( _
	inputHex As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As String

Parameters

inputHex
Hex-encoded input data
keyHex
Hex-encoded key representing exactly 8 bytes (64 bits)
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV representing exactly 8 bytes or "" for ECB mode

Return Value

Decrypted data in hex-encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (8 bytes)

Des.Decrypt Method (String, String, Mode, String, EncodingBase)

Decrypt encoded data string

Syntax

[C#]
public static string Decrypt(
	string inputStr,
	string keyStr,
	Mode mode,
	string ivStr,
	EncodingBase encodingBase
)
[VB.NET]
Public Shared Function Decrypt ( _
	inputStr As String, _
	keyStr As String, _
	mode As Mode, _
	ivStr As String, _
	encodingBase As EncodingBase _
) As String

Parameters

inputStr
Encoded input data
keyStr
Encoded key representing exactly 8 bytes (64 bits)
mode
Type: Mode
Cipher Mode
ivStr
Encoded IV representing exactly 8 bytes or "" for ECB mode
encodingBase
Type: EncodingBase
Type of encoding used

Return Value

Decrypted data in encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (8 bytes)

Des.Dispose Method

Dispose of this object and clear any key schedules

Syntax

[C#]
public void Dispose()
[VB.NET]
Public Sub Dispose

Des.Encrypt Method (Byte[], Byte[], Mode, Byte[])

Encrypt data in byte array

Syntax

[C#]
public static byte[] Encrypt(
	byte[] input,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function Encrypt ( _
	input As Byte(), _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Byte()

Parameters

input
Input data
key
Key of exactly 8 bytes (64 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Ciphertext in byte array or empty array on error

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (8 bytes)

Des.Encrypt Method (String, String, Mode, String)

Encrypt hex-encoded data string

Syntax

[C#]
public static string Encrypt(
	string inputHex,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function Encrypt ( _
	inputHex As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As String

Parameters

inputHex
Hex-encoded input data
keyHex
Hex-encoded key representing exactly 8 bytes (64 bits)
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV representing exactly 8 bytes or "" for ECB mode

Return Value

Ciphertext in hex-encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (8 bytes)

Des.Encrypt Method (String, String, Mode, String, EncodingBase)

Encrypt encoded data string

Syntax

[C#]
public static string Encrypt(
	string inputStr,
	string keyStr,
	Mode mode,
	string ivStr,
	EncodingBase encodingBase
)
[VB.NET]
Public Shared Function Encrypt ( _
	inputStr As String, _
	keyStr As String, _
	mode As Mode, _
	ivStr As String, _
	encodingBase As EncodingBase _
) As String

Parameters

inputStr
Encoded input data
keyStr
Encoded key representing exactly 8 bytes (64 bits)
mode
Type: Mode
Cipher Mode
ivStr
Encoded IV representing exactly 8 bytes or "" for ECB mode
encodingBase
Type: EncodingBase
Type of encoding used

Return Value

Ciphertext in encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (8 bytes)

Des.FileDecrypt Method (String, String, Byte[], Mode, Byte[])

Decrypt a file

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 8 bytes (64 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Des.FileDecrypt Method (String, String, Byte[], Mode, Byte[], CipherFileOption)

Decrypt a file with advanced options

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv,
	CipherFileOption advOptions
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte(), _
	advOptions As CipherFileOption _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 8 bytes (64 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes. Use null/Nothing for ECB mode or when using CipherFileOption.PrefixIV option
advOptions
Type: CipherFileOption
Advanced options. See CipherFileOption.

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Des.FileDecrypt Method (String, String, String, Mode, String)

Decrypt a file passing key and IV as hex strings

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
keyHex
Hex-encoded key of exact length
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV or "" for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same. The output file is in binary format.

Des.FileEncrypt Method (String, String, Byte[], Mode, Byte[])

Encrypt a file

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 8 bytes (64 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Des.FileEncrypt Method (String, String, Byte[], Mode, Byte[], CipherFileOption)

Encrypt a file with advanced options

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv,
	CipherFileOption advOptions
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte(), _
	advOptions As CipherFileOption _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 8 bytes (64 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode
advOptions
Type: CipherFileOption
Advanced options. See CipherFileOption.

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Des.FileEncrypt Method (String, String, String, Mode, String)

Encrypt a file passing key and IV as hex strings

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
keyHex
Hex-encoded key of exact length
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV or "" for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same. The output file is in binary format.

Des.InitDecrypt Method (Byte[], Mode, Byte[])

Initializes with key, mode and IV ready to start decrypting

Syntax

[C#]
public int InitDecrypt(
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Function InitDecrypt ( _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

key
Key of exactly 8 bytes (64 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Des.InitDecrypt Method (String, Mode, String)

Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

[C#]
public int InitDecrypt(
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Function InitDecrypt ( _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

keyHex
Key in hex-encoded format
mode
Type: Mode
Cipher mode
ivHex
IV in hex-encoded format

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Des.InitEncrypt Method (Byte[], Mode, Byte[])

Initializes with key, mode and IV ready to start encrypting

Syntax

[C#]
public int InitEncrypt(
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Function InitEncrypt ( _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

key
Key of exactly 8 bytes (64 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Des.InitEncrypt Method (String, Mode, String)

Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

[C#]
public int InitEncrypt(
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Function InitEncrypt ( _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

keyHex
Key in hex-encoded format
mode
Type: Mode
Cipher mode
ivHex
IV in hex-encoded format

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Des.Instance Method

Create the one and only instance

Syntax

[C#]
public static Des Instance()
[VB.NET]
Public Shared Function Instance As Des

Return Value

Single instance to class

Des.Pad Method (Byte[])

Pads byte array to correct length for ECB and CBC encryption

Syntax

[C#]
public static byte[] Pad(
	byte[] data
)
[VB.NET]
Public Shared Function Pad ( _
	data As Byte() _
) As Byte()

Parameters

data
data to be padded

Return Value

padded data in byte array

Remarks

Uses PKCS#5/#7/CMS method of padding

Des.Pad Method (String)

Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

[C#]
public static string Pad(
	string dataHex
)
[VB.NET]
Public Shared Function Pad ( _
	dataHex As String _
) As String

Parameters

dataHex
hex-encoded data to be padded

Return Value

padded data in hex-encoded string

Remarks

Uses PKCS#5/#7/CMS method of padding

Des.Unpad Method (Byte[])

Removes the padding from an encryption block

Syntax

[C#]
public static byte[] Unpad(
	byte[] data
)
[VB.NET]
Public Shared Function Unpad ( _
	data As Byte() _
) As Byte()

Parameters

data
padded data

Return Value

Unpadded data in byte array or unchanged data on error

Remarks

Padding is expected according to the convention in PKCS#5/#7/CMS. An error is indicated by returning the original data which will always be longer than the expected unpadded result.

Des.Unpad Method (String)

Removes the padding from a hex-encoded encryption block

Syntax

[C#]
public static string Unpad(
	string dataHex
)
[VB.NET]
Public Shared Function Unpad ( _
	dataHex As String _
) As String

Parameters

dataHex
hex-encoded padded data

Return Value

Unpadded data in hex-encoded string or unchanged data on error

Remarks

Padding is expected according to the convention in PKCS#5/#7/CMS. An error is indicated by returning the original data which will always be longer than the expected unpadded result.

Des.Update Method (Byte[])

Transforms byte input data with previously initialized key, mode and direction

Syntax

[C#]
public byte[] Update(
	byte[] data
)
[VB.NET]
Public Function Update ( _
	data As Byte() _
) As Byte()

Parameters

data
input data in byte array

Return Value

transformed data in byte array

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (8 bytes)

Des.Update Method (String)

Transforms hex string data with previously initialized key, mode and direction

Syntax

[C#]
public string Update(
	string data
)
[VB.NET]
Public Function Update ( _
	data As String _
) As String

Parameters

data
hex-encoded input data

Return Value

hex-encoded data

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (8 bytes)

Gcm.Decrypt Method

Decrypt input using AES-GCM in one-off operation

Syntax

[C#]
public static byte[] Decrypt(
	byte[] input,
	byte[] key,
	byte[] iv,
	byte[] aad,
	byte[] tag
)
[VB.NET]
Public Shared Function Decrypt ( _
	input As Byte(), _
	key As Byte(), _
	iv As Byte(), _
	aad As Byte(), _
	tag As Byte() _
) As Byte()

Parameters

input
Cipher text input data
key
Key: must be exactly 16, 24 or 32 bytes long.
iv
Initialization vector.
aad
Additional authentication data (optional). Pass null/Nothing to ignore.
tag
Tag value (required)

Return Value

Decrypted plaintext in byte array, or empty array on error

Remarks

Use General.ErrorCode to find the code of the last error.

Gcm.Dispose Method

Dispose of this object and clear any key schedules

Syntax

[C#]
public void Dispose()
[VB.NET]
Public Sub Dispose

Gcm.Encrypt Method

Encrypt input using AES-GCM in one-off operation

Syntax

[C#]
public static byte[] Encrypt(
	out byte[] tag,
	byte[] input,
	byte[] key,
	byte[] iv,
	byte[] aad
)
[VB.NET]
Public Shared Function Encrypt ( _
	<OutAttribute> ByRef tag As Byte(), _
	input As Byte(), _
	key As Byte(), _
	iv As Byte(), _
	aad As Byte() _
) As Byte()

Parameters

tag
To receive the output authentication tag value. Always returned exactly 16 bytes long. You may truncate as desired. This is a by-reference parameter. There is no need to initialize (but the VB compiler may complain).
input
Plain text input data
key
Key: must be exactly 16, 24 or 32 bytes long.
iv
Initialization vector: can be any length but 12 bytes is recommended.
aad
Additional authentication data (optional). Pass null/Nothing to ignore.

Return Value

Encrypted ciphertext in byte array, or empty array on error

Remarks

If you just require a GMAC value, use Gcm.Gmac Use General.ErrorCode to find the code of the last error.

Gcm.Gmac Method

Compute GMAC using AES-GCM in one-off operation

Syntax

[C#]
public static byte[] Gmac(
	byte[] key,
	byte[] iv,
	byte[] msg
)
[VB.NET]
Public Shared Function Gmac ( _
	key As Byte(), _
	iv As Byte(), _
	msg As Byte() _
) As Byte()

Parameters

key
Key: must be exactly 16, 24 or 32 bytes long.
iv
Initialization vector
msg
Message data

Return Value

GMAC value in 16-byte array, or empty array on error

Remarks

Use General.ErrorCode to find the code of the last error.

Gcm.InitKey Method

Initializes the context with the key ready for repeated operations of Gcm.NextEncrypt, Gcm.NextDecrypt, or Gcm.NextGmac.

Syntax

[C#]
public int InitKey(
	byte[] key
)
[VB.NET]
Public Function InitKey ( _
	key As Byte() _
) As Integer

Parameters

key
Key: must be exactly 16, 24 or 32 bytes long.

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

Once a key has been set up, Gcm.NextEncrypt, Gcm.NextDecrypt and Gcm.NextGmac can be used independently.

Example

[C#]
Gcm o = Instance;
o.InitKey(key);
byte[] tag = new byte[16];
byte[] ct = o.NextEncrypt(tag, pt, iv, aad);
//...
o.Dispose();

Gcm.Instance Method

Create the one and only instance

Syntax

[C#]
public static Gcm Instance()
[VB.NET]
Public Shared Function Instance As Gcm

Return Value

Single instance to class

Gcm.NextDecrypt Method

Carries out the GCM decryption operation using the key set up by an earlier call to Gcm.InitKey.

Syntax

[C#]
public byte[] NextDecrypt(
	byte[] input,
	byte[] iv,
	byte[] aad,
	byte[] tag
)
[VB.NET]
Public Function NextDecrypt ( _
	input As Byte(), _
	iv As Byte(), _
	aad As Byte(), _
	tag As Byte() _
) As Byte()

Parameters

input
Cipher text input data
iv
Initialization vector.
aad
Additional authentication data (optional). Pass null/Nothing to ignore.
tag
Tag value (required)

Return Value

Decrypted plaintext in byte array, or empty array on error

Gcm.NextEncrypt Method

Carries out the GCM encryption operation using the key set up by an earlier call to Gcm.InitKey.

Syntax

[C#]
public byte[] NextEncrypt(
	out byte[] tag,
	byte[] input,
	byte[] iv,
	byte[] aad
)
[VB.NET]
Public Function NextEncrypt ( _
	<OutAttribute> ByRef tag As Byte(), _
	input As Byte(), _
	iv As Byte(), _
	aad As Byte() _
) As Byte()

Parameters

tag
Tag value, always returned exactly 16 bytes long. You may truncate as desired.
input
Plain text input data
iv
Initialization vector: can be any length but 12 bytes is recommended.
aad
Additional authentication data (optional). Pass null/Nothing to ignore.

Return Value

Encrypted ciphertext in byte array, or empty array on error

Gcm.NextGmac Method

Carries out the GMAC operation using the key set up by an earlier call to Gcm.InitKey.

Syntax

[C#]
public byte[] NextGmac(
	byte[] iv,
	byte[] msg
)
[VB.NET]
Public Function NextGmac ( _
	iv As Byte(), _
	msg As Byte() _
) As Byte()

Parameters

iv
Initialization vector.
msg
Message data.

Return Value

GMAC value in byte array, or empty array on error

General.CompileTime Method

Gets date and time the CryptoSys DLL module was last compiled

Syntax

[C#]
public static string CompileTime()
[VB.NET]
Public Shared Function CompileTime As String

Return Value

Date and time string

General.ErrorCode Method

Returns the error code of the error that occurred when calling the last function

Syntax

[C#]
public static int ErrorCode()
[VB.NET]
Public Shared Function ErrorCode As Integer

Return Value

Error code

Remarks

Not all functions set this value.

General.ErrorLookup Method

Looks up error code

Syntax

[C#]
public static string ErrorLookup(
	int errCode
)
[VB.NET]
Public Shared Function ErrorLookup ( _
	errCode As Integer _
) As String

Parameters

errCode
Code number

Return Value

Corresponding error message

General.FormatErrorMessage Method

Return an error message string for the last error.

Syntax

[C#]
public static string FormatErrorMessage(
	int errCode
)
[VB.NET]
Public Shared Function FormatErrorMessage ( _
	errCode As Integer _
) As String

Parameters

errCode
Error code returned by last call (optional)

Return Value

Error message as a string Error ({errCode}): {errorlookup}[: {lasterror}]

General.IsWin64 Method

Returns flag indicating the platform of the core DLL.

Syntax

[C#]
public static int IsWin64()
[VB.NET]
Public Shared Function IsWin64 As Integer

Return Value

1 if platform is Win64 (X64) or 0 if Win32

General.LicenceType Method

Gets licence type.

Syntax

[C#]
public static char LicenceType()
[VB.NET]
Public Shared Function LicenceType As Char

Return Value

D=Developer T=Trial

General.ModuleInfo Method

Get additional information about the core DLL module.

Syntax

[C#]
public static string ModuleInfo()
[VB.NET]
Public Shared Function ModuleInfo As String

Return Value

[Missing <returns> documentation for M:CryptoSysAPI.General.ModuleInfo]


General.ModuleName Method

Gets full path name of core CryptoSys DLL module

Syntax

[C#]
public static string ModuleName()
[VB.NET]
Public Shared Function ModuleName As String

Return Value

File name

General.NetVersion Method

Return the version of this .NET module.

Syntax

[C#]
public static string NetVersion()
[VB.NET]
Public Shared Function NetVersion As String

Return Value

Version string, e.g. "03.05.00"

General.Platform Method

Return the platform the core DLL was compiled for.

Syntax

[C#]
public static string Platform()
[VB.NET]
Public Shared Function Platform As String

Return Value

"Win32" or "X64"

General.PowerUpTests Method

Performs FIPS-140-2 start-up tests

Syntax

[C#]
public static int PowerUpTests()
[VB.NET]
Public Shared Function PowerUpTests As Integer

Return Value

Zero on success

General.Version Method

Returns version number of core CryptoSys DLL.

Syntax

[C#]
public static int Version()
[VB.NET]
Public Shared Function Version As Integer

Return Value

Version number in form Major * 10000 + Minor * 100 + Release

Remarks

For example, version 5.2.1 returns 50201

Hash.AddData Method (Byte[])

Adds a chunk of data in a byte array to be digested by the Hash object.

Syntax

[C#]
public int AddData(
	byte[] b
)
[VB.NET]
Public Function AddData ( _
	b As Byte() _
) As Integer

Parameters

b
Data to add

Return Value

0 on success or nonzero error code

Hash.AddData Method (String)

Adds a chunk of data in a string to be digested by the Hash object.

Syntax

[C#]
public int AddData(
	string s
)
[VB.NET]
Public Function AddData ( _
	s As String _
) As Integer

Parameters

s
Data to add

Return Value

0 on success or nonzero error code

Hash.BytesFromBytes Method

Computes hash value in byte format of byte input

Syntax

[C#]
public static byte[] BytesFromBytes(
	byte[] message,
	HashAlgorithm hashAlg
)
[VB.NET]
Public Shared Function BytesFromBytes ( _
	message As Byte(), _
	hashAlg As HashAlgorithm _
) As Byte()

Parameters

message
Message data in byte format
hashAlg
Type: HashAlgorithm
Hash algorithm to be used

Return Value

Message digest in byte format

Hash.BytesFromFile Method

Computes hash value in byte format of a binary file

Syntax

[C#]
public static byte[] BytesFromFile(
	string fileName,
	HashAlgorithm hashAlg
)
[VB.NET]
Public Shared Function BytesFromFile ( _
	fileName As String, _
	hashAlg As HashAlgorithm _
) As Byte()

Parameters

fileName
Name of file containing message data
hashAlg
Type: HashAlgorithm
Hash algorithm to be used (ASCON-HASH not supported in file mode)

Return Value

Message digest in byte format

Hash.Dispose Method

Dispose of this object and clear any stored data.

Syntax

[C#]
public void Dispose()
[VB.NET]
Public Sub Dispose

Hash.Final Method

Computes final message digest for the Hash object.

Syntax

[C#]
public byte[] Final()
[VB.NET]
Public Function Final As Byte()

Return Value

Digest value in a byte array.

Remarks

This operation delivers the final result of Add operations since the Hash.Init() operation. Once called, the Hash object is invalid.

Hash.HexFromBits Method

Computes hash value in hex format from bit-oriented input

Syntax

[C#]
public static string HexFromBits(
	byte[] data,
	int dataBitLen,
	HashAlgorithm hashAlg
)
[VB.NET]
Public Shared Function HexFromBits ( _
	data As Byte(), _
	dataBitLen As Integer, _
	hashAlg As HashAlgorithm _
) As String

Parameters

data
Bit-oriented message data in byte array
dataBitLen
Number of bits in data to digest
hashAlg
Type: HashAlgorithm
Hash algorithm to be used (SHA-1, SHA-2, SHA-3 only)

Return Value

Message digest in hex-encoded format

Remarks

Only the SHA families of hash functions (SHA-1, SHA-2, SHA-3) are supported in bit-oriented mode

Hash.HexFromBytes Method

Computes hash value in hex format of byte input

Syntax

[C#]
public static string HexFromBytes(
	byte[] message,
	HashAlgorithm hashAlg
)
[VB.NET]
Public Shared Function HexFromBytes ( _
	message As Byte(), _
	hashAlg As HashAlgorithm _
) As String

Parameters

message
Message data in byte format
hashAlg
Type: HashAlgorithm
Hash algorithm to be used

Return Value

Message digest in hex-encoded format

Hash.HexFromFile Method

Computes hash value in hex format of a binary file

Syntax

[C#]
public static string HexFromFile(
	string fileName,
	HashAlgorithm hashAlg
)
[VB.NET]
Public Shared Function HexFromFile ( _
	fileName As String, _
	hashAlg As HashAlgorithm _
) As String

Parameters

fileName
Name of file containing message data
hashAlg
Type: HashAlgorithm
Hash algorithm to be used (ASCON-HASH not supported in file mode)

Return Value

Message digest in hex-encoded format

Hash.HexFromHex Method

Computes hash value in hex format of hex-encoded input

Syntax

[C#]
public static string HexFromHex(
	string messageHex,
	HashAlgorithm hashAlg
)
[VB.NET]
Public Shared Function HexFromHex ( _
	messageHex As String, _
	hashAlg As HashAlgorithm _
) As String

Parameters

messageHex
Message data in hex-encoded format
hashAlg
Type: HashAlgorithm
Hash algorithm to be used

Return Value

Message digest in hex-encoded format

Hash.HexFromString Method

Computes hash value in hex format of string input

Syntax

[C#]
public static string HexFromString(
	string message,
	HashAlgorithm hashAlg
)
[VB.NET]
Public Shared Function HexFromString ( _
	message As String, _
	hashAlg As HashAlgorithm _
) As String

Parameters

message
Message data string
hashAlg
Type: HashAlgorithm
Hash algorithm to be used

Return Value

Message digest in hex-encoded format

Hash.HexFromTextFile Method

Computes hash value in hex format of a text file, treating CR-LF pairs as a single LF

Syntax

[C#]
public static string HexFromTextFile(
	string fileName,
	HashAlgorithm hashAlg
)
[VB.NET]
Public Shared Function HexFromTextFile ( _
	fileName As String, _
	hashAlg As HashAlgorithm _
) As String

Parameters

fileName
Name of file containing message data
hashAlg
Type: HashAlgorithm
Hash algorithm to be used (ASCON-HASH not supported in file mode)

Return Value

Message digest in hex format

Remarks

Use for passing message digest of file between Unix and Windows systems.

Hash.Init Method

Initialises the Hash object ready for repeated incremental operations.

Syntax

[C#]
public bool Init(
	HashAlgorithm hashAlg
)
[VB.NET]
Public Function Init ( _
	hashAlg As HashAlgorithm _
) As Boolean

Parameters

hashAlg
Type: HashAlgorithm
Hash algorithm to be used (SHA-1, SHA-2, SHA-3 only)

Return Value

True if successful, False if failed

Remarks

Only the SHA families of hash functions (SHA-1, SHA-2, SHA-3) are supported in object mode.

Hash.Instance Method

Create the one and only instance

Syntax

[C#]
public static Hash Instance()
[VB.NET]
Public Shared Function Instance As Hash

Return Value

Single instance to class

Hash.LengthInBytes Method

Returns the number of bytes in the message digest for the given hash algorithm.

Syntax

[C#]
public static int LengthInBytes(
	HashAlgorithm hashAlg
)
[VB.NET]
Public Shared Function LengthInBytes ( _
	hashAlg As HashAlgorithm _
) As Integer

Parameters

hashAlg
Type: HashAlgorithm
Hash algorithm

Return Value

The length in bytes of the message digest output.

Hash.Reset Method

Resets the context of the Hash object.

Syntax

[C#]
public int Reset()
[VB.NET]
Public Function Reset As Integer

Return Value

0 on success or a nonzero error code.

Mac.AddData Method (Byte[])

Adds a chunk of data in a byte array to be authenticated by the Mac object.

Syntax

[C#]
public int AddData(
	byte[] b
)
[VB.NET]
Public Function AddData ( _
	b As Byte() _
) As Integer

Parameters

b
Data to add

Return Value

0 on success or nonzero error code

Mac.AddData Method (String)

Adds a chunk of data in a string to be authenticated by the Mac object.

Syntax

[C#]
public int AddData(
	string s
)
[VB.NET]
Public Function AddData ( _
	s As String _
) As Integer

Parameters

s
Data to add

Return Value

0 on success or nonzero error code

Mac.BytesFromBytes Method

Computes MAC value in byte format from byte input

Syntax

[C#]
public static byte[] BytesFromBytes(
	byte[] message,
	byte[] key,
	MacAlgorithm macAlg
)
[VB.NET]
Public Shared Function BytesFromBytes ( _
	message As Byte(), _
	key As Byte(), _
	macAlg As MacAlgorithm _
) As Byte()

Parameters

message
Message to be signed in byte format
key
Key in byte format
macAlg
Type: MacAlgorithm
MAC algorithm to be used

Return Value

MAC in byte format

Mac.Dispose Method

Dispose of this object and clear any stored data.

Syntax

[C#]
public void Dispose()
[VB.NET]
Public Sub Dispose

Mac.Final Method

Computes final MAC value for the Mac object.

Syntax

[C#]
public byte[] Final()
[VB.NET]
Public Function Final As Byte()

Return Value

MAC value in a byte array.

Remarks

This operation delivers the final result of Add operations since the Mac.Init() operation. Once called, the Mac object is invalid.

Mac.HexFromBytes Method

Computes MAC value in hex-encoded format from byte input

Syntax

[C#]
public static string HexFromBytes(
	byte[] message,
	byte[] key,
	MacAlgorithm macAlg
)
[VB.NET]
Public Shared Function HexFromBytes ( _
	message As Byte(), _
	key As Byte(), _
	macAlg As MacAlgorithm _
) As String

Parameters

message
Message to be signed in byte format
key
Key in byte format
macAlg
Type: MacAlgorithm
MAC algorithm to be used

Return Value

MAC in hex-encoded format

Mac.HexFromHex Method

Computes MAC value in hex-encoded format from hex-encoded input

Syntax

[C#]
public static string HexFromHex(
	string messageHex,
	string keyHex,
	MacAlgorithm macAlg
)
[VB.NET]
Public Shared Function HexFromHex ( _
	messageHex As String, _
	keyHex As String, _
	macAlg As MacAlgorithm _
) As String

Parameters

messageHex
Message to be signed in hex-encoded format
keyHex
Key in hex-encoded format
macAlg
Type: MacAlgorithm
MAC algorithm to be used

Return Value

MAC in hex-encoded format

Mac.Init Method

Initialises the Mac object ready for repeated incremental operations.

Syntax

[C#]
public bool Init(
	byte[] key,
	MacAlgorithm macAlg
)
[VB.NET]
Public Function Init ( _
	key As Byte(), _
	macAlg As MacAlgorithm _
) As Boolean

Parameters

key
Key
macAlg
Type: MacAlgorithm
HMAC algorithm to be used.

Return Value

True if successful, False if failed.

Remarks

Only the HMAC-SHA-1 and HMAC-SHA-2 families of MAC algorithms are currently supported in object mode.

Mac.Instance Method

Create the one and only instance

Syntax

[C#]
public static Mac Instance()
[VB.NET]
Public Shared Function Instance As Mac

Return Value

Single instance to class

Mac.Reset Method

Resets the context of the Mac object.

Syntax

[C#]
public int Reset()
[VB.NET]
Public Function Reset As Integer

Return Value

0 on success or a nonzero error code.

Md5.AddData Method (Byte[])

Adds an array of 8-bit bytes to the digest

Syntax

[C#]
public int AddData(
	byte[] b
)
[VB.NET]
Public Function AddData ( _
	b As Byte() _
) As Integer

Parameters

b
Data to add

Return Value

0 on success or nonzero error code

Md5.AddData Method (String)

Adds a string of Ansi characters to the digest

Syntax

[C#]
public int AddData(
	string s
)
[VB.NET]
Public Function AddData ( _
	s As String _
) As Integer

Parameters

s
String of Ansi characters

Return Value

0 on success or nonzero error code

Md5.BytesHash Method

Creates message digest as array of bytes from message in byte array

Syntax

[C#]
public static byte[] BytesHash(
	byte[] message
)
[VB.NET]
Public Shared Function BytesHash ( _
	message As Byte() _
) As Byte()

Parameters

message
Message data to be digested

Return Value

Digest in array of bytes

Md5.Dispose Method

Dispose of this object and clear any stored data

Syntax

[C#]
public void Dispose()
[VB.NET]
Public Sub Dispose

Md5.FileHexHash Method

Creates hash digest of a binary file

Syntax

[C#]
public static string FileHexHash(
	string fileName
)
[VB.NET]
Public Shared Function FileHexHash ( _
	fileName As String _
) As String

Parameters

fileName
Name of input file

Return Value

Message digest in hex format

Md5.FileTextHexHash Method

Creates hash digest of a "text" file treating CR-LF pairs as a single newline char

Syntax

[C#]
public static string FileTextHexHash(
	string fileName
)
[VB.NET]
Public Shared Function FileTextHexHash ( _
	fileName As String _
) As String

Parameters

fileName
Name of input file

Return Value

Message digest in hex format

Remarks

Use when comparing text data on a Unix system

Md5.HexDigest Method

Computes final message digest in hex format

Syntax

[C#]
public string HexDigest()
[VB.NET]
Public Function HexDigest As String

Return Value

Digest in hex format

Md5.HexHash Method (Byte[])

Creates message digest in hex format from message in byte array

Syntax

[C#]
public static string HexHash(
	byte[] message
)
[VB.NET]
Public Shared Function HexHash ( _
	message As Byte() _
) As String

Parameters

message
Message data to be digested

Return Value

Digest in hex format

Md5.HexHash Method (String)

Creates message digest in hex format from message in Ansi string

Syntax

[C#]
public static string HexHash(
	string message
)
[VB.NET]
Public Shared Function HexHash ( _
	message As String _
) As String

Parameters

message
Message text to be digested

Return Value

Digest in hex format

Md5.Hmac Method (Byte[], Byte[])

Computes the keyed hash digest of binary data using HMAC algorithm

Syntax

[C#]
public static string Hmac(
	byte[] data,
	byte[] key
)
[VB.NET]
Public Shared Function Hmac ( _
	data As Byte(), _
	key As Byte() _
) As String

Parameters

data
Data in array of bytes
key
Key in array of bytes

Return Value

Digest in hex format

Md5.Hmac Method (String, String)

Computes the keyed hash digest using HMAC algorithm passing data as hex strings

Syntax

[C#]
public static string Hmac(
	string dataHex,
	string keyHex
)
[VB.NET]
Public Shared Function Hmac ( _
	dataHex As String, _
	keyHex As String _
) As String

Parameters

dataHex
Data in hex format
keyHex
Key in hex format

Return Value

Digest in hex format

Md5.Init Method

Initializes the context

Syntax

[C#]
public bool Init()
[VB.NET]
Public Function Init As Boolean

Return Value

True if successful, False if failed

Md5.Instance Method

Create the one and only instance

Syntax

[C#]
public static Md5 Instance()
[VB.NET]
Public Shared Function Instance As Md5

Return Value

Single instance to class

Md5.Reset Method

Resets the context

Syntax

[C#]
public int Reset()
[VB.NET]
Public Function Reset As Integer

Return Value

0 on success or a nonzero error code

Pbe.Kdf2 Method (Int32, Byte[], Byte[], Int32, HashAlgorithm)

Derives a key of any length from a password using the PBKDF2 algorithm using specified HMAC algorithm

Syntax

[C#]
public static byte[] Kdf2(
	int dkLen,
	byte[] pwdBytes,
	byte[] salt,
	int count,
	HashAlgorithm hashAlg
)
[VB.NET]
Public Shared Function Kdf2 ( _
	dkLen As Integer, _
	pwdBytes As Byte(), _
	salt As Byte(), _
	count As Integer, _
	hashAlg As HashAlgorithm _
) As Byte()

Parameters

dkLen
Required length of key in bytes
pwdBytes
Password encoded in byte format
salt
Salt in byte format
count
Iteration count
hashAlg
Type: HashAlgorithm
Hash algorithm to use in HMAC PRF (optional, default=SHA-1)

Return Value

Key in byte[] format

Pbe.Kdf2 Method (Int32, String, String, Int32, HashAlgorithm)

Derives a key in hex format of any length from a password with the salt in hex format using specified HMAC algorithm

Syntax

[C#]
public static string Kdf2(
	int dkLen,
	string pwdStr,
	string saltHex,
	int count,
	HashAlgorithm hashAlg
)
[VB.NET]
Public Shared Function Kdf2 ( _
	dkLen As Integer, _
	pwdStr As String, _
	saltHex As String, _
	count As Integer, _
	hashAlg As HashAlgorithm _
) As String

Parameters

dkLen
Required length of key in bytes
pwdStr
Password
saltHex
Salt in hex format
count
Iteration count
hashAlg
Type: HashAlgorithm
Hash algorithm to use in HMAC PRF (optional, default=SHA-1)

Return Value

Key in hex format

Remarks

Password pwdStr is normal text, not hexadecimal

Example

[C#]
string keyHex = Pbe.Kdf2(24, "password", "78578e5a5d63cb06", 2048);
// BFDE6BE94DF7E11DD409BCE20A0255EC327CB936FFE93643

Pbe.Scrypt Method (Int32, Byte[], Byte[], Int32, Int32, Int32)

Derives a key of any length from a password using the SCRYPT algorithm.

Syntax

[C#]
public static byte[] Scrypt(
	int dkLen,
	byte[] pwdBytes,
	byte[] salt,
	int N,
	int r,
	int p
)
[VB.NET]
Public Shared Function Scrypt ( _
	dkLen As Integer, _
	pwdBytes As Byte(), _
	salt As Byte(), _
	N As Integer, _
	r As Integer, _
	p As Integer _
) As Byte()

Parameters

dkLen
Required length of key in bytes
pwdBytes
Password encoded in byte format
salt
Salt in byte format
N
CPU/Memory cost parameter, a number greater than one and a power of 2.
r
Block size r
p
Parallelization parameter p

Return Value

Key in byte[] format

Pbe.Scrypt Method (Int32, String, String, Int32, Int32, Int32)

Derives a key in hex format from a password with the salt in hex format

Syntax

[C#]
public static string Scrypt(
	int dkLen,
	string pwdStr,
	string saltHex,
	int N,
	int r,
	int p
)
[VB.NET]
Public Shared Function Scrypt ( _
	dkLen As Integer, _
	pwdStr As String, _
	saltHex As String, _
	N As Integer, _
	r As Integer, _
	p As Integer _
) As String

Parameters

dkLen
Required length of key in bytes
pwdStr
Password (normal text)
saltHex
Salt in hex format
N
CPU/Memory cost parameter, a number greater than one and a power of 2.
r
Block size r
p
Parallelization parameter p

Return Value

Key in hex format

Remarks

Password pwdStr is normal text, not hexadecimal

Example

[C#]
string keyHex = Pbe.Scrypt(64, "password", "4E61436C", 1024, 8, 16);

Pc1.Encrypt Method (Byte[], Byte[])

Encrypt byte array input using RC4-compatible algorithm

Syntax

[C#]
public static byte[] Encrypt(
	byte[] input,
	byte[] key
)
[VB.NET]
Public Shared Function Encrypt ( _
	input As Byte(), _
	key As Byte() _
) As Byte()

Parameters

input
input byte array, any length
key
key byte array, any length

Return Value

byte array

Remarks

Superseded by Cipher.StreamBytes()

Pc1.Encrypt Method (String, String)

Encrypt hex-encoded input using RC4-compatible algorithm

Syntax

[C#]
public static string Encrypt(
	string inputHex,
	string keyHex
)
[VB.NET]
Public Shared Function Encrypt ( _
	inputHex As String, _
	keyHex As String _
) As String

Parameters

inputHex
hex-encoded input, any length
keyHex
hex-encoded key, any length

Return Value

hex-encoded string

Remarks

Superseded by Cipher.StreamHex()

Pc1.File Method

Encrypt a file using RC4-compatible algorithm

Syntax

[C#]
public static int File(
	string fileOut,
	string fileIn,
	byte[] key
)
[VB.NET]
Public Shared Function File ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte() _
) As Integer

Parameters

fileOut
Full pathname of output file to be created. Must be different from fileIn
fileIn
Full pathname of input file
key
Key byte array, any length

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

Superseded by Cipher.StreamFile()

Prf.Bytes Method

Generate output bytes using a pseudorandom function (PRF).

Syntax

[C#]
public static byte[] Bytes(
	int numBytes,
	byte[] message,
	byte[] key,
	string customStr,
	PrfAlgorithm prfAlg
)
[VB.NET]
Public Shared Function Bytes ( _
	numBytes As Integer, _
	message As Byte(), _
	key As Byte(), _
	customStr As String, _
	prfAlg As PrfAlgorithm _
) As Byte()

Parameters

numBytes
Required number of output bytes.
message
Input message data.
key
Key.
customStr
Customization string (optional).
prfAlg
Type: PrfAlgorithm
PRF algorithm.

Return Value

Output data in byte array.

Rng.BytesWithPrompt Method (Int32, Rng.Strength)

Generates an array of random bytes with a prompt for keyboard input

Syntax

[C#]
public static byte[] BytesWithPrompt(
	int numBytes,
	Rng.Strength strength
)
[VB.NET]
Public Shared Function BytesWithPrompt ( _
	numBytes As Integer, _
	strength As Rng.Strength _
) As Byte()

Parameters

numBytes
Required number of random bytes
strength
Type: Rng.Strength
Required security strength (default=112 bits)

Return Value

Array of random bytes

Rng.BytesWithPrompt Method (Int32, String, Rng.Strength)

Generates an array of random bytes with a prompt for keyboard input

Syntax

[C#]
public static byte[] BytesWithPrompt(
	int numBytes,
	string prompt,
	Rng.Strength strength
)
[VB.NET]
Public Shared Function BytesWithPrompt ( _
	numBytes As Integer, _
	prompt As String, _
	strength As Rng.Strength _
) As Byte()

Parameters

numBytes
Required number of random bytes
prompt
Alternative prompt. Set as an empty string "" for the default prompt.
strength
Type: Rng.Strength
Required security strength

Return Value

Array of random bytes

Rng.HexWithPrompt Method (Int32)

Generates random bytes in hex format with a prompt for keyboard input

Syntax

[C#]
public static string HexWithPrompt(
	int numBytes
)
[VB.NET]
Public Shared Function HexWithPrompt ( _
	numBytes As Integer _
) As String

Parameters

numBytes
Required number of random bytes

Return Value

Random bytes in hex format

Rng.HexWithPrompt Method (Int32, String, Rng.Strength)

Generates random bytes in hex format with a prompt for keyboard input

Syntax

[C#]
public static string HexWithPrompt(
	int numBytes,
	string prompt,
	Rng.Strength strength
)
[VB.NET]
Public Shared Function HexWithPrompt ( _
	numBytes As Integer, _
	prompt As String, _
	strength As Rng.Strength _
) As String

Parameters

numBytes
Required number of random bytes
prompt
Alternative prompt. Set as an empty string "" for the default prompt.
strength
Type: Rng.Strength
Required security strength

Return Value

Random bytes in hex format

Rng.Initialize Method

Initialize the RNG generator with a seed file.

Syntax

[C#]
public static bool Initialize(
	string seedFile
)
[VB.NET]
Public Shared Function Initialize ( _
	seedFile As String _
) As Boolean

Parameters

seedFile
Full path name of seed file

Return Value

true if successful; false if fails

Remarks

A seed file maintains the entropy state between sessions. It is automatically updated by this procedure. If the seed file does not exist, it will be created (with any available entropy).

Rng.InitializeEx Method

Query and initialize the RNG generator using Intel(R) DRNG, if available.

Syntax

[C#]
public static int InitializeEx(
	Rng.Options opts
)
[VB.NET]
Public Shared Function InitializeEx ( _
	opts As Rng.Options _
) As Integer

Parameters

opts
Type: Rng.Options
Specify Rng.Options.NoIntelDrng to explicitly turn off support.

Return Value

Support status for Intel(R) DRNG. If available, then a positive value (1,2,3); else a negative error code.

Rng.KeyBytes Method (Int32, Byte[])

Generates a random key with user-supplied entropy

Syntax

[C#]
public static byte[] KeyBytes(
	int numBytes,
	byte[] arrSeed
)
[VB.NET]
Public Shared Function KeyBytes ( _
	numBytes As Integer, _
	arrSeed As Byte() _
) As Byte()

Parameters

numBytes
Required number of random bytes
arrSeed
User-supplied entropy in byte format

Return Value

Array of random bytes

Rng.KeyBytes Method (Int32, String)

Generates a random key

Syntax

[C#]
public static byte[] KeyBytes(
	int numBytes,
	string seedStr
)
[VB.NET]
Public Shared Function KeyBytes ( _
	numBytes As Integer, _
	seedStr As String _
) As Byte()

Parameters

numBytes
Required number of random bytes
seedStr
User-supplied entropy in string format. Set as an empty string "" to ignore.

Return Value

Array of random bytes

Rng.KeyHex Method (Int32, Byte[])

Generates a random key in hex format with user-supplied entropy

Syntax

[C#]
public static string KeyHex(
	int numBytes,
	byte[] arrSeed
)
[VB.NET]
Public Shared Function KeyHex ( _
	numBytes As Integer, _
	arrSeed As Byte() _
) As String

Parameters

numBytes
Required number of random bytes
arrSeed
User-supplied entropy in byte format

Return Value

Random bytes in hex format

Rng.KeyHex Method (Int32, String)

Generates a random key in hex format

Syntax

[C#]
public static string KeyHex(
	int numBytes,
	string seedStr
)
[VB.NET]
Public Shared Function KeyHex ( _
	numBytes As Integer, _
	seedStr As String _
) As String

Parameters

numBytes
Required number of random bytes
seedStr
User-supplied entropy in string format. Set as an empty string "" to ignore.

Return Value

Random bytes in hex format

Rng.MakeSeedFile Method (String, Rng.Strength)

Create a new seed file suitable for use with Rng.Initialize

Syntax

[C#]
public static bool MakeSeedFile(
	string seedFile,
	Rng.Strength strength
)
[VB.NET]
Public Shared Function MakeSeedFile ( _
	seedFile As String, _
	strength As Rng.Strength _
) As Boolean

Parameters

seedFile
Name of seed file to be created
strength
Type: Rng.Strength
Required security strength (default=112 bits)

Return Value

true if successful; false if fails

Remarks

Any existing file of the same name will be overwritten without warning.

Rng.MakeSeedFile Method (String, String, Rng.Strength)

Create a new seed file suitable for use with Rng.Initialize

Syntax

[C#]
public static bool MakeSeedFile(
	string seedFile,
	string prompt,
	Rng.Strength strength
)
[VB.NET]
Public Shared Function MakeSeedFile ( _
	seedFile As String, _
	prompt As String, _
	strength As Rng.Strength _
) As Boolean

Parameters

seedFile
Name of seed file to be created
prompt
Prompt for dialog
strength
Type: Rng.Strength
Required security strength

Return Value

true if successful; false if fails

Remarks

Any existing file of the same name will be overwritten without warning.

Rng.NonceBytes Method

Generates a random nonce

Syntax

[C#]
public static byte[] NonceBytes(
	int numBytes
)
[VB.NET]
Public Shared Function NonceBytes ( _
	numBytes As Integer _
) As Byte()

Parameters

numBytes
Number of bytes required

Return Value

Array of bytes

Rng.NonceHex Method

Generates a random nonce in hex format

Syntax

[C#]
public static string NonceHex(
	int numBytes
)
[VB.NET]
Public Shared Function NonceHex ( _
	numBytes As Integer _
) As String

Parameters

numBytes
Number of bytes required

Return Value

Nonce in hex format

Rng.Number Method

Generates a random integer in a given range

Syntax

[C#]
public static int Number(
	int lower,
	int upper
)
[VB.NET]
Public Shared Function Number ( _
	lower As Integer, _
	upper As Integer _
) As Integer

Parameters

lower
lower value of range
upper
upper value of range

Return Value

Random integer

Rng.Octet Method

Generates a single random octet (byte)

Syntax

[C#]
public static byte Octet()
[VB.NET]
Public Shared Function Octet As Byte

Return Value

Single byte value randomly chosen between 0 and 255

Rng.Test Method

Carries out a NIST SP800-90 health check and FIPS140-2 statistical tests on the random number generator

Syntax

[C#]
public static bool Test(
	string resultFile
)
[VB.NET]
Public Shared Function Test ( _
	resultFile As String _
) As Boolean

Parameters

resultFile
Name of results file to be created, or null/Nothing not to create a results file.

Return Value

true if successful; false if fails.

Remarks

Any existing file of the same name will be overwritten without warning.

Rng.TestDrbgvs Method

Tests the random number generator for conformance to NIST SP 800-90A using the relevant test specified in the Deterministic Random Bit Generator Validation System (DRBGVS).

Syntax

[C#]
public static string TestDrbgvs(
	int returnedBitsLen,
	string entropyInput,
	string nonce,
	string personalizationString,
	string additionalInput1,
	string entropyReseed,
	string additionalInputReseed,
	string additionalInput2
)
[VB.NET]
Public Shared Function TestDrbgvs ( _
	returnedBitsLen As Integer, _
	entropyInput As String, _
	nonce As String, _
	personalizationString As String, _
	additionalInput1 As String, _
	entropyReseed As String, _
	additionalInputReseed As String, _
	additionalInput2 As String _
) As String

Parameters

returnedBitsLen
Number of bits to be returned from each call to the generate function in the test
entropyInput
the EntropyInput value in hex format
nonce
the Nonce value in hex format
personalizationString
the PersonalizationString value in hex format
additionalInput1
the first AdditionalInput value in hex format
entropyReseed
the EntropyReseed value in hex format
additionalInputReseed
the AdditionalInputReseed value in hex format
additionalInput2
the second AdditionalInput value in hex format

Return Value

the ReturnedBits as a string in hexadecimal format

Remarks

The test procedure, the input values and the expected output are described in the DRBGVS document. The relevant DRBG mechanism is HMAC_DRBG SHA-512 without prediction resistance. Use the empty string "" to pass a zero-length input. All hex strings must have an even number of characters.

Rng.UpdateSeedFile Method

Updates the RNG seed file

Syntax

[C#]
public static bool UpdateSeedFile(
	string seedFile
)
[VB.NET]
Public Shared Function UpdateSeedFile ( _
	seedFile As String _
) As Boolean

Parameters

seedFile
Full path name of seed file

Return Value

true if successful; false if fails

Remarks

Any existing file of the same name will be overwritten without warning.

Sha1.AddData Method (Byte[])

Adds an array of 8-bit bytes to the digest

Syntax

[C#]
public int AddData(
	byte[] b
)
[VB.NET]
Public Function AddData ( _
	b As Byte() _
) As Integer

Parameters

b
Data to add

Return Value

0 on success or nonzero error code

Sha1.AddData Method (String)

Adds a string of Ansi characters to the digest

Syntax

[C#]
public int AddData(
	string s
)
[VB.NET]
Public Function AddData ( _
	s As String _
) As Integer

Parameters

s
String of Ansi characters

Return Value

0 on success or nonzero error code

Sha1.BytesHash Method

Creates message digest as array of bytes from message in byte array

Syntax

[C#]
public static byte[] BytesHash(
	byte[] message
)
[VB.NET]
Public Shared Function BytesHash ( _
	message As Byte() _
) As Byte()

Parameters

message
Message data to be digested

Return Value

Digest in array of bytes

Sha1.Dispose Method

Dispose of this object and clear any stored data

Syntax

[C#]
public void Dispose()
[VB.NET]
Public Sub Dispose

Sha1.FileHexHash Method

Creates hash digest of a binary file

Syntax

[C#]
public static string FileHexHash(
	string fileName
)
[VB.NET]
Public Shared Function FileHexHash ( _
	fileName As String _
) As String

Parameters

fileName
Name of input file

Return Value

Message digest in hex format

Sha1.FileTextHexHash Method

Creates hash digest of a "text" file treating CR-LF pairs as a single newline char

Syntax

[C#]
public static string FileTextHexHash(
	string fileName
)
[VB.NET]
Public Shared Function FileTextHexHash ( _
	fileName As String _
) As String

Parameters

fileName
Name of input file

Return Value

Message digest in hex format

Remarks

Use when comparing text data on a Unix system

Sha1.HexDigest Method

Computes final message digest in hex format

Syntax

[C#]
public string HexDigest()
[VB.NET]
Public Function HexDigest As String

Return Value

Digest in hex format

Sha1.HexHash Method (Byte[])

Creates message digest in hex format from message in byte array

Syntax

[C#]
public static string HexHash(
	byte[] message
)
[VB.NET]
Public Shared Function HexHash ( _
	message As Byte() _
) As String

Parameters

message
Message data to be digested

Return Value

Digest in hex format

Sha1.HexHash Method (String)

Creates message digest in hex format from message in Ansi string

Syntax

[C#]
public static string HexHash(
	string message
)
[VB.NET]
Public Shared Function HexHash ( _
	message As String _
) As String

Parameters

message
Message text to be digested

Return Value

Digest in hex format

Sha1.Hmac Method (Byte[], Byte[])

Computes the keyed hash digest of binary data using HMAC algorithm

Syntax

[C#]
public static string Hmac(
	byte[] data,
	byte[] key
)
[VB.NET]
Public Shared Function Hmac ( _
	data As Byte(), _
	key As Byte() _
) As String

Parameters

data
Data in array of bytes
key
Key in array of bytes

Return Value

Digest in hex format

Sha1.Hmac Method (String, String)

Computes the keyed hash digest using HMAC algorithm passing data as hex strings

Syntax

[C#]
public static string Hmac(
	string dataHex,
	string keyHex
)
[VB.NET]
Public Shared Function Hmac ( _
	dataHex As String, _
	keyHex As String _
) As String

Parameters

dataHex
Data in hex format
keyHex
Key in hex format

Return Value

Digest in hex format

Sha1.Init Method

Initializes the context

Syntax

[C#]
public bool Init()
[VB.NET]
Public Function Init As Boolean

Return Value

True if successful, False if failed

Sha1.Instance Method

Create the one and only instance

Syntax

[C#]
public static Sha1 Instance()
[VB.NET]
Public Shared Function Instance As Sha1

Return Value

Single instance to class

Sha1.Reset Method

Resets the context

Syntax

[C#]
public int Reset()
[VB.NET]
Public Function Reset As Integer

Return Value

0 on success or a nonzero error code

Sha256.AddData Method (Byte[])

Adds an array of 8-bit bytes to the digest

Syntax

[C#]
public int AddData(
	byte[] b
)
[VB.NET]
Public Function AddData ( _
	b As Byte() _
) As Integer

Parameters

b
Data to add

Return Value

0 on success or nonzero error code

Sha256.AddData Method (String)

Adds a string of Ansi characters to the digest

Syntax

[C#]
public int AddData(
	string s
)
[VB.NET]
Public Function AddData ( _
	s As String _
) As Integer

Parameters

s
String of Ansi characters

Return Value

0 on success or nonzero error code

Sha256.BytesHash Method

Creates message digest as array of bytes from message in byte array

Syntax

[C#]
public static byte[] BytesHash(
	byte[] message
)
[VB.NET]
Public Shared Function BytesHash ( _
	message As Byte() _
) As Byte()

Parameters

message
Message data to be digested

Return Value

Digest in array of bytes

Sha256.Dispose Method

Dispose of this object and clear any stored data

Syntax

[C#]
public void Dispose()
[VB.NET]
Public Sub Dispose

Sha256.FileHexHash Method

Creates hash digest of a binary file

Syntax

[C#]
public static string FileHexHash(
	string fileName
)
[VB.NET]
Public Shared Function FileHexHash ( _
	fileName As String _
) As String

Parameters

fileName
Name of input file

Return Value

Message digest in hex format

Sha256.FileTextHexHash Method

Creates hash digest of a "text" file treating CR-LF pairs as a single newline char

Syntax

[C#]
public static string FileTextHexHash(
	string fileName
)
[VB.NET]
Public Shared Function FileTextHexHash ( _
	fileName As String _
) As String

Parameters

fileName
Name of input file

Return Value

Message digest in hex format

Remarks

Use when comparing text data on a Unix system

Sha256.HexDigest Method

Computes final message digest in hex format

Syntax

[C#]
public string HexDigest()
[VB.NET]
Public Function HexDigest As String

Return Value

Digest in hex format

Sha256.HexHash Method (Byte[])

Creates message digest in hex format from message in byte array

Syntax

[C#]
public static string HexHash(
	byte[] message
)
[VB.NET]
Public Shared Function HexHash ( _
	message As Byte() _
) As String

Parameters

message
Message data to be digested

Return Value

Digest in hex format

Sha256.HexHash Method (String)

Creates message digest in hex format from message in Ansi string

Syntax

[C#]
public static string HexHash(
	string message
)
[VB.NET]
Public Shared Function HexHash ( _
	message As String _
) As String

Parameters

message
Message text to be digested

Return Value

Digest in hex format

Sha256.Hmac Method (Byte[], Byte[])

Computes the keyed hash digest of binary data using HMAC algorithm

Syntax

[C#]
public static string Hmac(
	byte[] data,
	byte[] key
)
[VB.NET]
Public Shared Function Hmac ( _
	data As Byte(), _
	key As Byte() _
) As String

Parameters

data
Data in array of bytes
key
Key in array of bytes

Return Value

Digest in hex format

Sha256.Hmac Method (String, String)

Computes the keyed hash digest using HMAC algorithm passing data as hex strings

Syntax

[C#]
public static string Hmac(
	string dataHex,
	string keyHex
)
[VB.NET]
Public Shared Function Hmac ( _
	dataHex As String, _
	keyHex As String _
) As String

Parameters

dataHex
Data in hex format
keyHex
Key in hex format

Return Value

Digest in hex format

Sha256.Init Method

Initializes the context

Syntax

[C#]
public bool Init()
[VB.NET]
Public Function Init As Boolean

Return Value

True if successful, False if failed

Sha256.Instance Method

Create the one and only instance

Syntax

[C#]
public static Sha256 Instance()
[VB.NET]
Public Shared Function Instance As Sha256

Return Value

Single instance to class

Sha256.Reset Method

Resets the context

Syntax

[C#]
public int Reset()
[VB.NET]
Public Function Reset As Integer

Return Value

0 on success or a nonzero error code

Sha3.AddData Method (Byte[])

Adds an array of 8-bit bytes to the digest

Syntax

[C#]
public int AddData(
	byte[] b
)
[VB.NET]
Public Function AddData ( _
	b As Byte() _
) As Integer

Parameters

b
Data to add

Return Value

0 on success or nonzero error code

Sha3.AddData Method (String)

Adds a string of Ansi characters to the digest

Syntax

[C#]
public int AddData(
	string s
)
[VB.NET]
Public Function AddData ( _
	s As String _
) As Integer

Parameters

s
String of Ansi characters

Return Value

0 on success or nonzero error code

Sha3.Dispose Method

Dispose of this object and clear any stored data

Syntax

[C#]
public void Dispose()
[VB.NET]
Public Sub Dispose

Sha3.HexDigest Method

Computes final message digest in hex format

Syntax

[C#]
public string HexDigest()
[VB.NET]
Public Function HexDigest As String

Return Value

Digest in hex format

Sha3.Init Method

Initialises the object ready to receive data to digest

Syntax

[C#]
public bool Init(
	int hashBitLen
)
[VB.NET]
Public Function Init ( _
	hashBitLen As Integer _
) As Boolean

Parameters

hashBitLen
Size of SHA-3 algorithm in bits. Must be one of {224, 256, 384, 512}.

Return Value

True if successful, False if failed

Sha3.Instance Method

Create the one and only instance

Syntax

[C#]
public static Sha3 Instance()
[VB.NET]
Public Shared Function Instance As Sha3

Return Value

Single instance to class

Sha3.Reset Method

Resets the context

Syntax

[C#]
public int Reset()
[VB.NET]
Public Function Reset As Integer

Return Value

0 on success or a nonzero error code

Tdea.CheckKey Method (Byte[])

Verifies that no part of the key is a weak or semi-weak TDEA key.

Syntax

[C#]
public static int CheckKey(
	byte[] key
)
[VB.NET]
Public Shared Function CheckKey ( _
	key As Byte() _
) As Integer

Parameters

key
Key to check

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Tdea.CheckKey Method (String)

Verifies that no part of the key is a weak or semi-weak TDEA key.

Syntax

[C#]
public static int CheckKey(
	string keyHex
)
[VB.NET]
Public Shared Function CheckKey ( _
	keyHex As String _
) As Integer

Parameters

keyHex
Hex-encoded key to check

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Tdea.Decrypt Method (Byte[], Byte[], Mode, Byte[])

Decrypt data in byte array

Syntax

[C#]
public static byte[] Decrypt(
	byte[] input,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function Decrypt ( _
	input As Byte(), _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Byte()

Parameters

input
Input data
key
Key of exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Decrypted data in byte array or empty array on error

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (8 bytes)

Tdea.Decrypt Method (String, String, Mode, String)

Decrypt hex-encoded data string

Syntax

[C#]
public static string Decrypt(
	string inputHex,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function Decrypt ( _
	inputHex As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As String

Parameters

inputHex
Hex-encoded input data
keyHex
Hex-encoded key representing exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV representing exactly 8 bytes or "" for ECB mode

Return Value

Decrypted data in hex-encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (8 bytes)

Tdea.Decrypt Method (String, String, Mode, String, EncodingBase)

Decrypt encoded data string

Syntax

[C#]
public static string Decrypt(
	string inputStr,
	string keyStr,
	Mode mode,
	string ivStr,
	EncodingBase encodingBase
)
[VB.NET]
Public Shared Function Decrypt ( _
	inputStr As String, _
	keyStr As String, _
	mode As Mode, _
	ivStr As String, _
	encodingBase As EncodingBase _
) As String

Parameters

inputStr
Encoded input data
keyStr
Encoded key representing exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
ivStr
Encoded IV representing exactly 8 bytes or "" for ECB mode
encodingBase
Type: EncodingBase
Type of encoding used

Return Value

Decrypted data in encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (8 bytes)

Tdea.Dispose Method

Dispose of this object and clear any key schedules

Syntax

[C#]
public void Dispose()
[VB.NET]
Public Sub Dispose

Tdea.Encrypt Method (Byte[], Byte[], Mode, Byte[])

Encrypt data in byte array

Syntax

[C#]
public static byte[] Encrypt(
	byte[] input,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function Encrypt ( _
	input As Byte(), _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Byte()

Parameters

input
Input data
key
Key of exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Ciphertext in byte array or empty array on error

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (8 bytes)

Tdea.Encrypt Method (String, String, Mode, String)

Encrypt hex-encoded data string

Syntax

[C#]
public static string Encrypt(
	string inputHex,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function Encrypt ( _
	inputHex As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As String

Parameters

inputHex
Hex-encoded input data
keyHex
Hex-encoded key representing exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV representing exactly 8 bytes or "" for ECB mode

Return Value

Ciphertext in hex-encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (8 bytes)

Tdea.Encrypt Method (String, String, Mode, String, EncodingBase)

Encrypt encoded data string

Syntax

[C#]
public static string Encrypt(
	string inputStr,
	string keyStr,
	Mode mode,
	string ivStr,
	EncodingBase encodingBase
)
[VB.NET]
Public Shared Function Encrypt ( _
	inputStr As String, _
	keyStr As String, _
	mode As Mode, _
	ivStr As String, _
	encodingBase As EncodingBase _
) As String

Parameters

inputStr
Encoded input data
keyStr
Encoded key representing exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
ivStr
Encoded IV representing exactly 8 bytes or "" for ECB mode
encodingBase
Type: EncodingBase
Type of encoding used

Return Value

Ciphertext in encoded string or empty string on error

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (8 bytes)

Tdea.FileDecrypt Method (String, String, Byte[], Mode, Byte[])

Decrypt a file

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Tdea.FileDecrypt Method (String, String, Byte[], Mode, Byte[], CipherFileOption)

Decrypt a file with advanced options

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv,
	CipherFileOption advOptions
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte(), _
	advOptions As CipherFileOption _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes. Use null/Nothing for ECB mode or when using CipherFileOption.PrefixIV option
advOptions
Type: CipherFileOption
Advanced options. See CipherFileOption.

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Tdea.FileDecrypt Method (String, String, String, Mode, String)

Decrypt a file passing key and IV as hex strings

Syntax

[C#]
public static int FileDecrypt(
	string fileOut,
	string fileIn,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function FileDecrypt ( _
	fileOut As String, _
	fileIn As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
keyHex
Hex-encoded key of exact length
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV or "" for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same. The output file is in binary format.

Tdea.FileEncrypt Method (String, String, Byte[], Mode, Byte[])

Encrypt a file

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Tdea.FileEncrypt Method (String, String, Byte[], Mode, Byte[], CipherFileOption)

Encrypt a file with advanced options

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	byte[] key,
	Mode mode,
	byte[] iv,
	CipherFileOption advOptions
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	key As Byte(), _
	mode As Mode, _
	iv As Byte(), _
	advOptions As CipherFileOption _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
key
Key of exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode
advOptions
Type: CipherFileOption
Advanced options. See CipherFileOption.

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same

Tdea.FileEncrypt Method (String, String, String, Mode, String)

Encrypt a file passing key and IV as hex strings

Syntax

[C#]
public static int FileEncrypt(
	string fileOut,
	string fileIn,
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Shared Function FileEncrypt ( _
	fileOut As String, _
	fileIn As String, _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

fileOut
Name of output file to be created or overwritten
fileIn
Name of input file
keyHex
Hex-encoded key of exact length
mode
Type: Mode
Cipher Mode
ivHex
Hex-encoded IV or "" for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Remarks

fileOut and fileIn must not be the same. The output file is in binary format.

Tdea.InitDecrypt Method (Byte[], Mode, Byte[])

Initializes with key, mode and IV ready to start decrypting

Syntax

[C#]
public int InitDecrypt(
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Function InitDecrypt ( _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

key
Key of exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Tdea.InitDecrypt Method (String, Mode, String)

Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

[C#]
public int InitDecrypt(
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Function InitDecrypt ( _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

keyHex
Key in hex-encoded format
mode
Type: Mode
Cipher mode
ivHex
IV in hex-encoded format

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Tdea.InitEncrypt Method (Byte[], Mode, Byte[])

Initializes with key, mode and IV ready to start encrypting

Syntax

[C#]
public int InitEncrypt(
	byte[] key,
	Mode mode,
	byte[] iv
)
[VB.NET]
Public Function InitEncrypt ( _
	key As Byte(), _
	mode As Mode, _
	iv As Byte() _
) As Integer

Parameters

key
Key of exactly 24 bytes (192 bits)
mode
Type: Mode
Cipher Mode
iv
IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Tdea.InitEncrypt Method (String, Mode, String)

Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

[C#]
public int InitEncrypt(
	string keyHex,
	Mode mode,
	string ivHex
)
[VB.NET]
Public Function InitEncrypt ( _
	keyHex As String, _
	mode As Mode, _
	ivHex As String _
) As Integer

Parameters

keyHex
Key in hex-encoded format
mode
Type: Mode
Cipher mode
ivHex
IV in hex-encoded format

Return Value

Zero (0) if successful; otherwise it returns a nonzero error code

Tdea.Instance Method

Create the one and only instance

Syntax

[C#]
public static Tdea Instance()
[VB.NET]
Public Shared Function Instance As Tdea

Return Value

Single instance to class

Tdea.Pad Method (Byte[])

Pads byte array to correct length for ECB and CBC encryption

Syntax

[C#]
public static byte[] Pad(
	byte[] data
)
[VB.NET]
Public Shared Function Pad ( _
	data As Byte() _
) As Byte()

Parameters

data
data to be padded

Return Value

padded data in byte array

Remarks

Uses PKCS#5/#7/CMS method of padding

Tdea.Pad Method (String)

Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

[C#]
public static string Pad(
	string dataHex
)
[VB.NET]
Public Shared Function Pad ( _
	dataHex As String _
) As String

Parameters

dataHex
hex-encoded data to be padded

Return Value

padded data in hex-encoded string

Remarks

Uses PKCS#5/#7/CMS method of padding

Tdea.Unpad Method (Byte[])

Removes the padding from an encryption block

Syntax

[C#]
public static byte[] Unpad(
	byte[] data
)
[VB.NET]
Public Shared Function Unpad ( _
	data As Byte() _
) As Byte()

Parameters

data
padded data

Return Value

Unpadded data in byte array or unchanged data on error

Remarks

Padding is expected according to the convention in PKCS#5/#7/CMS. An error is indicated by returning the original data which will always be longer than the expected unpadded result.

Tdea.Unpad Method (String)

Removes the padding from a hex-encoded encryption block

Syntax

[C#]
public static string Unpad(
	string dataHex
)
[VB.NET]
Public Shared Function Unpad ( _
	dataHex As String _
) As String

Parameters

dataHex
hex-encoded padded data

Return Value

Unpadded data in hex-encoded string or unchanged data on error

Remarks

Padding is expected according to the convention in PKCS#5/#7/CMS. An error is indicated by returning the original data which will always be longer than the expected unpadded result.

Tdea.Update Method (Byte[])

Transform byte input data with previously initialized key, mode and direction

Syntax

[C#]
public byte[] Update(
	byte[] data
)
[VB.NET]
Public Function Update ( _
	data As Byte() _
) As Byte()

Parameters

data
input data in byte array

Return Value

transformed data in byte array

Remarks

For ECB and CBC modes, input data length must be an exact multiple of the block length (8 bytes)

Tdea.Update Method (String)

Transform hex string data with previously initialized key, mode and direction

Syntax

[C#]
public string Update(
	string data
)
[VB.NET]
Public Function Update ( _
	data As String _
) As String

Parameters

data
hex-encoded input data

Return Value

hex-encoded data

Remarks

For ECB and CBC modes, the length of the decoded input bytes must be an exact multiple of the block length (8 bytes)

Wipe.Data Method

Zeroises data in memory

Syntax

[C#]
public static bool Data(
	byte[] data
)
[VB.NET]
Public Shared Function Data ( _
	data As Byte() _
) As Boolean

Parameters

data
data to be wiped

Return Value

true if successful; false if fails

Wipe.File Method

Securely wipe and delete a file.

Syntax

[C#]
public static bool File(
	string fileName,
	Wipe.Options opts
)
[VB.NET]
Public Shared Function File ( _
	fileName As String, _
	opts As Wipe.Options _
) As Boolean

Parameters

fileName
Name of file to be wiped
opts
Type: Wipe.Options
Options (optional) Default is DOD 7-pass.

Return Value

true if successful; false if fails

Wipe.String Method

Zeroises a StringBuilder

Syntax

[C#]
public static bool String(
	StringBuilder sb
)
[VB.NET]
Public Shared Function String ( _
	sb As StringBuilder _
) As Boolean

Parameters

sb
StringBuilder to be wiped

Return Value

true if successful; false if fails

Remarks

NB You can't wipe an ordinary string as they are immutable in C#, so store any sensitive string data in a StringBuilder.

Xof.Bytes Method

Generate bytes using an extendable-output function (XOF).

Syntax

[C#]
public static byte[] Bytes(
	int numBytes,
	byte[] message,
	XofAlgorithm xofAlg
)
[VB.NET]
Public Shared Function Bytes ( _
	numBytes As Integer, _
	message As Byte(), _
	xofAlg As XofAlgorithm _
) As Byte()

Parameters

numBytes
Required number of output bytes.
message
Input message data.
xofAlg
Type: XofAlgorithm
XOF algorithm.

Return Value

Output data in byte array.

Zlib.Deflate Method

Compress data using the ZLIB deflate algorithm

Syntax

[C#]
public static byte[] Deflate(
	byte[] dataToComp
)
[VB.NET]
Public Shared Function Deflate ( _
	dataToComp As Byte() _
) As Byte()

Parameters

dataToComp
Data to be compressed

Return Value

Compressed data

Zlib.Inflate Method (Byte[])

Inflate compressed data using the ZLIB algorithm.

Syntax

[C#]
public static byte[] Inflate(
	byte[] data
)
[VB.NET]
Public Shared Function Inflate ( _
	data As Byte() _
) As Byte()

Parameters

data
Compressed data to be uncompressed.

Return Value

Uncompressed data, or an empty array on error.

Remarks

An empty array may also be returned if the original data was the empty array itself.

Zlib.Inflate Method (Byte[], Int32)

Inflate compressed data using the ZLIB algorithm [superseded].

Syntax

[C#]
public static byte[] Inflate(
	byte[] data,
	int lenUncompressed
)
[VB.NET]
Public Shared Function Inflate ( _
	data As Byte(), _
	lenUncompressed As Integer _
) As Byte()

Parameters

data
Data to be uncompressed
lenUncompressed
Length of uncompressed data

Return Value

Uncompressed data

Remarks

Superseded by Zlib.Inflate(Byte[])

Aead.ErrCode Property

Last error code (object-related only)

Syntax

[C#]
public int ErrCode { get; }
[VB.NET]
Public ReadOnly Property ErrCode As Integer

Aes128.ErrCode Property

Last error code (for Init and Update methods only)

Syntax

[C#]
public int ErrCode { get; }
[VB.NET]
Public ReadOnly Property ErrCode As Integer

Aes192.ErrCode Property

Last error code (for Init and Update methods only)

Syntax

[C#]
public int ErrCode { get; }
[VB.NET]
Public ReadOnly Property ErrCode As Integer

Aes256.ErrCode Property

Last error code (for Init and Update methods only)

Syntax

[C#]
public int ErrCode { get; }
[VB.NET]
Public ReadOnly Property ErrCode As Integer

Blowfish.ErrCode Property

Last error code (for Init and Update methods only)

Syntax

[C#]
public int ErrCode { get; }
[VB.NET]
Public ReadOnly Property ErrCode As Integer

Cipher.ErrCode Property

Last error code (for Init, Update and Final object methods only)

Syntax

[C#]
public int ErrCode { get; }
[VB.NET]
Public ReadOnly Property ErrCode As Integer

CipherStream.ErrCode Property

Last error code (for Init and Update methods only)

Syntax

[C#]
public int ErrCode { get; }
[VB.NET]
Public ReadOnly Property ErrCode As Integer

Des.ErrCode Property

Last error code (for Init and Update methods only)

Syntax

[C#]
public int ErrCode { get; }
[VB.NET]
Public ReadOnly Property ErrCode As Integer

Gcm.ErrCode Property

Last error code (object-related only)

Syntax

[C#]
public int ErrCode { get; }
[VB.NET]
Public ReadOnly Property ErrCode As Integer

Hash.ErrCode Property

Last error code (for Init, AddData and Final object methods only)

Syntax

[C#]
public int ErrCode { get; }
[VB.NET]
Public ReadOnly Property ErrCode As Integer

Mac.ErrCode Property

Last error code (for Init, AddData and Final object methods only)

Syntax

[C#]
public int ErrCode { get; }
[VB.NET]
Public ReadOnly Property ErrCode As Integer

Md5.ErrCode Property

Last error code (for Init, AddData and HexDigest methods only)

Syntax

[C#]
public int ErrCode { get; }
[VB.NET]
Public ReadOnly Property ErrCode As Integer

Sha1.ErrCode Property

Last error code (for Init, AddData and HexDigest methods only)

Syntax

[C#]
public int ErrCode { get; }
[VB.NET]
Public ReadOnly Property ErrCode As Integer

Sha256.ErrCode Property

Last error code (for Init, AddData and HexDigest methods only)

Syntax

[C#]
public int ErrCode { get; }
[VB.NET]
Public ReadOnly Property ErrCode As Integer

Sha3.ErrCode Property

Last error code (for Init, AddData and HexDigest methods only)

Syntax

[C#]
public int ErrCode { get; }
[VB.NET]
Public ReadOnly Property ErrCode As Integer

Sha3.LengthInBytes Property

Length in bytes of hash output (i.e. length in bits / 8)

Syntax

[C#]
public int LengthInBytes { get; }
[VB.NET]
Public ReadOnly Property LengthInBytes As Integer

Tdea.ErrCode Property

Last error code (for Init and Update methods only)

Syntax

[C#]
public int ErrCode { get; }
[VB.NET]
Public ReadOnly Property ErrCode As Integer

Enumerations

Aead.Algorithm Enumeration

AEAD algorithm

Syntax

[C#]
public enum Algorithm
[VB.NET]
Public Enumeration Algorithm

Members

Member nameDescription
Aes_128_Gcm
AEAD_AES_128_GCM authenticated encryption algorithm (RFC 5116)
Aes_256_Gcm
AEAD_AES_256_GCM authenticated encryption algorithm (RFC 5116)
Chacha20_Poly1305
AEAD_CHACHA20_POLY1305 authenticated encryption algorithm (RFC 7539)
Ascon_128
ASCON-128 authenticated encryption (Aead.[En/De]cryptWithTag only)
Ascon_128A
ASCON-128a authenticated encryption (Aead.[En/De]cryptWithTag only)

Aead.Opts Enumeration

Advanced options

Syntax

[C#]
[FlagsAttribute]
public enum Opts
[VB.NET]
<FlagsAttribute> _
Public Enumeration Opts

Members

Member nameDescription
Default
Default options
PrefixIV
Prefix (prepend) the IV (nonce) before the ciphertext in the output

CipherAlgorithm Enumeration

Block Cipher Algorithm

Syntax

[C#]
public enum CipherAlgorithm
[VB.NET]
Public Enumeration CipherAlgorithm

Members

Member nameDescription
Tdea
Triple DES (TDEA, 3DES, des-ede3)
Aes128
AES-128
Aes192
AES-192
Aes256
AES-256

CipherFileOption Enumeration

Advanced options for file cipher operations

Syntax

[C#]
[FlagsAttribute]
public enum CipherFileOption
[VB.NET]
<FlagsAttribute> _
Public Enumeration CipherFileOption

Members

Member nameDescription
Default
Default option
PrefixIV
Prefix the IV before ciphertext in the output file (ignored for ECB mode)
LeavePadding
Leave any padding in place when decrypting (ECB and CBC modes only; ignored if encrypting)

CipherStream.Algorithm Enumeration

Stream cipher algorithm

Syntax

[C#]
public enum Algorithm
[VB.NET]
Public Enumeration Algorithm

Members

Member nameDescription
Arcfour
ARCFOUR (RC4) algorithm
Salsa20
Salsa20 algorithm
Chacha20
ChaCha20 algorithm

Cipher.Opts Enumeration

Advanced options

Syntax

[C#]
[FlagsAttribute]
public enum Opts
[VB.NET]
<FlagsAttribute> _
Public Enumeration Opts

Members

Member nameDescription
Default
Default options
PrefixIV
Prefix (prepend) the IV before the ciphertext in the output file (ignored for ECB mode)

ComprAlgorithm Enumeration

Compression algorithm.

Syntax

[C#]
public enum ComprAlgorithm
[VB.NET]
Public Enumeration ComprAlgorithm

Members

Member nameDescription
Zlib
zlib as per RFC 1950
Zstd
zstd as per RFC 8878

EncodingBase Enumeration

Base for encoding methods

Syntax

[C#]
public enum EncodingBase
[VB.NET]
Public Enumeration EncodingBase

Members

Member nameDescription
Base64
Base64 encoding
Base16
Base16 encoding (i.e. hexadecimal)

HashAlgorithm Enumeration

Message Digest Hash Algorithm

Syntax

[C#]
public enum HashAlgorithm
[VB.NET]
Public Enumeration HashAlgorithm

Members

Member nameDescription
Sha1
SHA-1 (as per FIPS PUB 180-2)
Md5
MD5 (as per RFC 1321)
Md2
MD2 (as per RFC 1319)
Ripemd160
RIPEMD-160
Sha224
SHA-224 (as per FIPS PUB 180-4)
Sha256
SHA-256 (as per FIPS PUB 180-4)
Sha384
SHA-384 (as per FIPS PUB 180-4)
Sha512
SHA-512 (as per FIPS PUB 180-4)
Sha3_224
SHA-3-224 (as per FIPS PUB 202)
Sha3_256
SHA-3-256 (as per FIPS PUB 202)
Sha3_384
SHA-3-384 (as per FIPS PUB 202)
Sha3_512
SHA-3-256 (as per FIPS PUB 202)
Ascon_Hash
ASCON-HASH (byte/hex functions only)
Ascon_HashA
ASCON-HASHA (byte/hex functions only)

MacAlgorithm Enumeration

Message Authentication Code (MAC) Algorithm

Syntax

[C#]
public enum MacAlgorithm
[VB.NET]
Public Enumeration MacAlgorithm

Members

Member nameDescription
HmacSha1
HMAC-SHA-1
HmacMd5
HMAC-MD5
HmacRipemd160
HMAC-RIPEMD160
HmacSha224
HMAC-SHA-224
HmacSha256
HMAC-SHA-256
HmacSha384
HMAC-SHA-384
HmacSha512
HMAC-SHA-512
HmacSha3_224
HMAC-SHA-3-224
HmacSha3_256
HMAC-SHA-3-256
HmacSha3_384
HMAC-SHA-3-384
HmacSha3_512
HMAC-SHA-3-512
CmacTdea
CMAC-TDEA (CMAC-DES-EDE)
CmacAes128
CMAC-AES-128
CmacAes192
CMAC-AES-192
CmacAes256
CMAC-AES-256
Poly1305
Poly1305
Kmac128
KMAC128 with a fixed-length output of 256 bits (32 bytes)
Kmac256
KMAC256 with a fixed-length output of 512 bits (64 bytes)

Mode Enumeration

Cipher Mode

Syntax

[C#]
public enum Mode
[VB.NET]
Public Enumeration Mode

Members

Member nameDescription
ECB
Electronic Code Book mode
CBC
Cipher Block Chaining mode
OFB
Output Feedback mode
CFB
Cipher Feedback mode
CTR
Counter mode

Padding Enumeration

Block Cipher Padding

Syntax

[C#]
public enum Padding
[VB.NET]
Public Enumeration Padding

Members

Member nameDescription
Default
Use default padding
NoPad
No padding is added
Pkcs5
The padding scheme described in PKCS#5
OneAndZeroes
Pads with 0x80 followed by as many zero bytes necessary to fill the block
AnsiX923
The padding scheme described in ANSI X9.23
W3CPadding
The padding scheme described in W3C https://www.w3.org/TR/xmlenc-core1/#sec-Padding

PrfAlgorithm Enumeration

Pseudorandom function (PRF) algorithm.

Syntax

[C#]
public enum PrfAlgorithm
[VB.NET]
Public Enumeration PrfAlgorithm

Members

Member nameDescription
Kmac128
KMAC128 as per NIST SP 800-185
Kmac256
KMAC256 as per NIST SP 800-185

Rng.Options Enumeration

Rng options

Syntax

[C#]
public enum Options
[VB.NET]
Public Enumeration Options

Members

Member nameDescription
Default
Default option
NoIntelDrng
Turn off support for INTEL(R) DRNG for the current session.

Rng.Strength Enumeration

Required security strength for user-prompted entropy

Syntax

[C#]
public enum Strength
[VB.NET]
Public Enumeration Strength

Members

Member nameDescription
Default
Default option
Bits_112
112 bits of security (default)
Bits_128
128 bits of security
Bits_192
192 bits of security
Bits_256
256 bits of security

Wipe.Options Enumeration

Wipe options.

Syntax

[C#]
public enum Options
[VB.NET]
Public Enumeration Options

Members

Member nameDescription
Default
Default options (DOD 7-pass)
Dod7Pass
DOD 7-pass (default)
Simple
Overwrite with single pass of zero bytes (quicker but less secure).

XofAlgorithm Enumeration

Extendable-output function (XOF) algorithm.

Syntax

[C#]
public enum XofAlgorithm
[VB.NET]
Public Enumeration XofAlgorithm

Members

Member nameDescription
Shake128
SHAKE128 as per FIPS PUB 202
Shake256
SHAKE256 as per FIPS PUB 202
Mgf1_Sha1
MGF1-SHA-1 (as per PKCS#1)
Mgf1_Sha256
MGF1-SHA-256 (as per PKCS#1)
Mgf1_Sha512
MGF1-SHA-512 (as per PKCS#1)
Ascon_Xof
ASCON-XOF extendable output function
Ascon_XofA
ASCON-XOFA extendable output function

Index

Aead Class
Aes128 Class
Aes192 Class
Aes256 Class
Blowfish Class
Cipher Class
CipherStream Class
Classes
Cnv Class
Compr Class
Crc Class
CryptoSysAPI Namespace
Des Class
Enumerations
Gcm Class
General Class
Hash Class
Mac Class
Md5 Class
Methods
Pbe Class
Pc1 Class
Prf Class
Rng Class
Sha1 Class
Sha256 Class
Sha3 Class
Tdea Class
Wipe Class
Xof Class
Zlib Class