CryptoSysAPI Namespace

.NET interface to CryptoSys API.

Classes

Class Description
Aead Provides generic authenticated encryption.
Aes128 Advanced Encryption Standard (AES) with 128-bit key
Aes192 Advanced Encryption Standard (AES) with 192-bit key
Aes256 Advanced Encryption Standard (AES) with 256-bit key
Blowfish Blowfish cipher algorithm
Cipher Block cipher utilities
CipherStream Stream cipher algorithms
Cnv Character conversion routines
Compr Compression utilities
Crc CRC-32 computations
Des Data Encryption Standard (DES) Cipher (legacy applications only)
Gcm Provides authenticated encryption using the Galois/Counter Mode (GCM) of operation with the AES algorithm (AES-GCM).
General General functions
Hash Message Digest Hash Functions
Mac Message authentication code (MAC) functions
Md5 MD5 Hash Algorithm
Pbe Password-based encryption
Pc1 RC4-compatible stream cipher algorithm (superseded by Cipher.Stream methods)
Prf Pseudorandom function (PRF) methods.
Rng Random Number Generator to NIST SP800-90
Sha1 Secure Hash Algorithm 1 (SHA-1)
Sha256 Secure Hash 256 Algorithm (SHA-256)
Sha3 Secure Hash Algorithm SHA-3
Tdea Triple DES Cipher (3DES, TDEA, DES-EDE3)
Wipe Data Wiping Functions
Xof Extendable-output function (XOF) methods.
Zlib ZLIB compression algorithm

Enumerations

Enumeration Description
Aead.Algorithm AEAD algorithm
Aead.Opts Advanced options
Cipher.Opts Advanced options
CipherAlgorithm Block Cipher Algorithm
CipherFileOption Advanced options for file cipher operations
CipherStream.Algorithm Stream cipher algorithm
ComprAlgorithm Compression algorithm.
EncodingBase Base for encoding methods
HashAlgorithm Message Digest Hash Algorithm
MacAlgorithm Message Authentication Code (MAC) Algorithm
Mode Cipher Mode
Padding Block Cipher Padding
PrfAlgorithm Pseudorandom function (PRF) algorithm.
Rng.Options Rng options
Rng.Strength Required security strength for user-prompted entropy
Wipe.Options Wipe options.
XofAlgorithm Extendable-output function (XOF) algorithm.

Aead Class

Provides generic authenticated encryption.

Inheritance Hierarchy

System.Object
CryptoSysAPI.Aead

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Aead : IDisposable

The Aead type exposes the following members.

Properties

Name Description
ErrCode Last error code (object-related only)

Methods

Name Description
AddAAD Add a chunk of additional authenticated data (in incremental mode)
Authenticate Authenticate additional data using tag
Decrypt Decrypt and authenticate input using specified AEAD algorithm in one-off operation
DecryptWithTag(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.
DecryptWithTag(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.
Dispose Dispose of this object and clear any key schedules
Encrypt Encrypt input using specified AEAD algorithm in one-off operation.
EncryptWithTag(Byte[], Byte[], Byte[], Aead.Algorithm) Encrypt data using specified AEAD algorithm in one-off operation. The authentication tag is appended to the output.
EncryptWithTag(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.
FinishDecrypt Finishes the authenticated decryption (in incremental mode)
FinishEncrypt Finishes the authenticated encryption (in incremental mode)
InitKey Initializes the context with the key and algorithm ready for repeated incremental operations
Instance Create the one and only instance
Mac Compute Message Authentication Code (tag) over input data
SetNonce Set the nonce (in incremental mode)
StartDecrypt Start authenticated decryption (in incremental mode)
StartEncrypt Start authenticated encryption (in incremental mode)
Update Encrypts or decrypts a chunk of input (in incremental mode)

Fields

Name Description
TagMaxSize Maximum size of tag in bytes

See Also

CryptoSysAPI Namespace

Aead.ErrCode Property

Last error code (object-related only)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int ErrCode { get; }

Property Value

Int32

See Also

Aead Class
CryptoSysAPI Namespace

Aead.AddAAD Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int AddAAD(
    byte[] aad
)

Parameters

aad Byte[]

Chunk of additional data to add

Return Value

Int32
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().

See Also

Aead Class
CryptoSysAPI Namespace

General.ErrorLookup Method

Looks up error code

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string ErrorLookup(
    int errCode
)

Parameters

errCode Int32

Code number

Return Value

String
Corresponding error message

See Also

General Class
CryptoSysAPI Namespace

Aead.Authenticate Method

Authenticate additional data using tag

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static bool Authenticate(
    byte[] key,
    byte[] nonce,
    byte[] aad,
    byte[] tag,
    Aead.Algorithm alg
)

Parameters

key Byte[]

Key of exact length for given algorithm (16 or 32 bytes).

nonce Byte[]

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

aad Byte[]

Data to be authenticated

tag Byte[]

Tag value

alg Aead.Algorithm

AEAD algorithm to use

Return Value

Boolean
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.

See Also

Aead Class
CryptoSysAPI Namespace

General.ErrorCode Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static int ErrorCode()

Return Value

Int32
Error code

Remarks

Not all functions set this value.

See Also

General Class
CryptoSysAPI Namespace

Aead.Decrypt Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] Decrypt(
    byte[] input,
    byte[] key,
    byte[] nonce,
    byte[] aad,
    byte[] tag,
    Aead.Algorithm alg
)

Parameters

input Byte[]

Cipher text input data (required)

key Byte[]

Key of exact length for given algorithm (16 or 32 bytes).

nonce Byte[]

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

aad Byte[]

Additional authentication data (optional). Pass null/Nothing to ignore.

tag Byte[]

Tag value (required)

alg Aead.Algorithm

AEAD algorithm to use

Return Value

Byte[]
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.

See Also

Aead Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
DecryptWithTag(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.
DecryptWithTag(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

public static byte[] DecryptWithTag(
    byte[] input,
    byte[] key,
    byte[] iv,
    Aead.Algorithm aeadAlg
)

Parameters

input Byte[]

Input data to be decrypted.

key Byte[]

Key of exact length for algorithm (16 or 32 bytes).

iv Byte[]

Initialization Vector (IV) (aka nonce) (12 or 16 bytes).

aeadAlg Aead.Algorithm

Authenticated encryption algorithm.

Return Value

Byte[]
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).

See Also

Aead Class
CryptoSysAPI Namespace

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

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.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
DecryptWithTag(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.
DecryptWithTag(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

public static byte[] DecryptWithTag(
    byte[] input,
    byte[] key,
    byte[] iv,
    byte[] aad,
    Aead.Algorithm aeadAlg,
    Aead.Opts opts
)

Parameters

input Byte[]

Input data to be decrypted.

key Byte[]

Key of exact length for algorithm (16 or 32 bytes).

iv Byte[]

(optional) Initialization Vector (IV) (aka nonce) exactly 12 bytes long. Set as null if already prefixed to input.

aad Byte[]

Additional authenticated data (optional) - set as null to ignore.

aeadAlg Aead.Algorithm

Authenticated encryption algorithm.

opts Aead.Opts

Advanced options. Use Aead.Opts.PrefixIV to expect the IV to be prepended at the start of the input.

Return Value

Byte[]
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.

See Also

Aead Class
CryptoSysAPI Namespace

Aead.Dispose Method

Dispose of this object and clear any key schedules

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public void Dispose()

Implements

IDisposable.Dispose()

See Also

Aead Class
CryptoSysAPI Namespace

Aead.Encrypt Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] Encrypt(
    out byte[] tag,
    byte[] input,
    byte[] key,
    byte[] nonce,
    byte[] aad,
    Aead.Algorithm alg
)

Parameters

tag Byte[]

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 Byte[]

Plain text input data (required)

key Byte[]

Key of exact length for given algorithm (16 or 32 bytes)

nonce Byte[]

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

aad Byte[]

Additional authentication data (optional). Pass null/Nothing to ignore.

alg Aead.Algorithm

AEAD algorithm to use

Return Value

Byte[]
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.

See Also

Aead Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
EncryptWithTag(Byte[], Byte[], Byte[], Aead.Algorithm) Encrypt data using specified AEAD algorithm in one-off operation. The authentication tag is appended to the output.
EncryptWithTag(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

public static byte[] EncryptWithTag(
    byte[] input,
    byte[] key,
    byte[] iv,
    Aead.Algorithm aeadAlg
)

Parameters

input Byte[]

Input data to be encrypted.

key Byte[]

Key of exact length for algorithm (16 or 32 bytes).

iv Byte[]

Initialization Vector (IV) (aka nonce) (16 bytes for ASCON-128 else 12 bytes).

aeadAlg Aead.Algorithm

Authenticated encryption algorithm.

Return Value

Byte[]
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.

See Also

Aead Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
EncryptWithTag(Byte[], Byte[], Byte[], Aead.Algorithm) Encrypt data using specified AEAD algorithm in one-off operation. The authentication tag is appended to the output.
EncryptWithTag(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

public static byte[] EncryptWithTag(
    byte[] input,
    byte[] key,
    byte[] iv,
    byte[] aad,
    Aead.Algorithm aeadAlg,
    Aead.Opts opts = Aead.Opts.Default
)

Parameters

input Byte[]

Input data to be encrypted.

key Byte[]

Key of exact length for algorithm (16 or 32 bytes).

iv Byte[]

Initialization Vector (IV) (aka nonce) (16 bytes for ASCON-128 else 12 bytes).

aad Byte[]

Additional authenticated data (optional) - set as null to ignore.

aeadAlg Aead.Algorithm

Authenticated encryption algorithm.

opts Aead.Opts (Optional)

Advanced options (optional). Use Opts.PrefixIV to prepend the IV to the output

Return Value

Byte[]
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.

See Also

Aead Class
CryptoSysAPI Namespace

Aead.FinishDecrypt Method

Finishes the authenticated decryption (in incremental mode)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public bool FinishDecrypt()

Return Value

Boolean
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().

See Also

Aead Class
CryptoSysAPI Namespace

Aead.FinishEncrypt Method

Finishes the authenticated encryption (in incremental mode)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public byte[] FinishEncrypt()

Return Value

Byte[]
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().

See Also

Aead Class
CryptoSysAPI Namespace

Aead.InitKey Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int InitKey(
    byte[] key,
    Aead.Algorithm alg
)

Parameters

key Byte[]

Key of exact length for given algorithm (16 or 32 bytes).

alg Aead.Algorithm

AEAD algorithm to use

Return Value

Int32
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

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

See Also

Aead Class
CryptoSysAPI Namespace

Aead.Instance Method

Create the one and only instance

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static Aead Instance()

Return Value

Aead
Single instance to class

See Also

Aead Class
CryptoSysAPI Namespace

Aead.Mac Method

Compute Message Authentication Code (tag) over input data

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] Mac(
    byte[] key,
    byte[] nonce,
    byte[] aad,
    Aead.Algorithm alg
)

Parameters

key Byte[]

Key of exact length for given algorithm (16 or 32 bytes).

nonce Byte[]

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

aad Byte[]

Data to be authenticated

alg Aead.Algorithm

AEAD algorithm to use

Return Value

Byte[]
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.

See Also

Aead Class
CryptoSysAPI Namespace

Aead.SetNonce Method

Set the nonce (in incremental mode)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int SetNonce(
    byte[] nonce
)

Parameters

nonce Byte[]

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

Return Value

Int32
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().

See Also

Aead Class
CryptoSysAPI Namespace

Aead.StartDecrypt Method

Start authenticated decryption (in incremental mode)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int StartDecrypt(
    byte[] tagToCheck
)

Parameters

tagToCheck Byte[]

Tag value to be authenticated

Return Value

Int32
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.

See Also

Aead Class
CryptoSysAPI Namespace

Aead.StartEncrypt Method

Start authenticated encryption (in incremental mode)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int StartEncrypt()

Return Value

Int32
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().

See Also

Aead Class
CryptoSysAPI Namespace

Aead.Update Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public byte[] Update(
    byte[] input
)

Parameters

input Byte[]

Data to be encrypted or decrypted

Return Value

Byte[]
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.

See Also

Aead Class
CryptoSysAPI Namespace

Aead.TagMaxSize Field

Maximum size of tag in bytes

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public const int TagMaxSize = 16

Field Value

Int32

See Also

Aead Class
CryptoSysAPI Namespace

Aes128 Class

Advanced Encryption Standard (AES) with 128-bit key

Inheritance Hierarchy

System.Object
CryptoSysAPI.Aes128

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Aes128 : IDisposable

The Aes128 type exposes the following members.

Properties

Name Description
ErrCode Last error code (for Init and Update methods only)

Methods

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string
Dispose Dispose of this object and clear any key schedules
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting
Instance Create the one and only instance
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction
Update(String) Transform hex string data with previously initialized key, mode and direction

Fields

Name Description
BlockSize Block size in bytes

See Also

CryptoSysAPI Namespace

Aes128.ErrCode Property

Last error code (for Init and Update methods only)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int ErrCode { get; }

Property Value

Int32

See Also

Aes128 Class
CryptoSysAPI Namespace

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

Decrypt data in byte array

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static byte[] Decrypt(
    byte[] input,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

input Byte[]

Input data

key Byte[]

Key of exactly 16 bytes (128 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Byte[]
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)

See Also

Aes128 Class
CryptoSysAPI Namespace

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

Decrypt hex-encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static string Decrypt(
    string inputHex,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

inputHex String

Hex-encoded input data

keyHex String

Hex-encoded key representing exactly 16 bytes (128 bits)

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV representing exactly 16 bytes or "" for ECB mode

Return Value

String
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)

See Also

Aes128 Class
CryptoSysAPI Namespace

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

Decrypt encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static string Decrypt(
    string inputStr,
    string keyStr,
    Mode mode,
    string ivStr,
    EncodingBase encodingBase
)

Parameters

inputStr String

Encoded input data

keyStr String

Encoded key representing exactly 16 bytes (128 bits)

mode Mode

Cipher Mode

ivStr String

Encoded IV representing exactly 16 bytes or "" for ECB mode

encodingBase EncodingBase

Type of encoding used

Return Value

String
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)

See Also

Aes128 Class
CryptoSysAPI Namespace

Aes128.Dispose Method

Dispose of this object and clear any key schedules

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public void Dispose()

Implements

IDisposable.Dispose()

See Also

Aes128 Class
CryptoSysAPI Namespace

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

Encrypt data in byte array

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static byte[] Encrypt(
    byte[] input,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

input Byte[]

Input data

key Byte[]

Key of exactly 16 bytes (128 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Byte[]
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)

See Also

Aes128 Class
CryptoSysAPI Namespace

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

Encrypt hex-encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static string Encrypt(
    string inputHex,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

inputHex String

Hex-encoded input data

keyHex String

Hex-encoded key representing exactly 16 bytes (128 bits)

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV representing exactly 16 bytes or "" for ECB mode

Return Value

String
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)

See Also

Aes128 Class
CryptoSysAPI Namespace

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

Encrypt encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static string Encrypt(
    string inputStr,
    string keyStr,
    Mode mode,
    string ivStr,
    EncodingBase encodingBase
)

Parameters

inputStr String

Encoded input data

keyStr String

Encoded key representing exactly 16 bytes (128 bits)

mode Mode

Cipher Mode

ivStr String

Encoded IV representing exactly 16 bytes or "" for ECB mode

encodingBase EncodingBase

Type of encoding used

Return Value

String
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)

See Also

Aes128 Class
CryptoSysAPI Namespace

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

Decrypt a file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 16 bytes (128 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Aes128 Class
CryptoSysAPI Namespace

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

Decrypt a file passing key and IV as hex strings

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

keyHex String

Hex-encoded key of exact length

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV or "" for ECB mode

Return Value

Int32
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.

See Also

Aes128 Class
CryptoSysAPI Namespace

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

Decrypt a file with advanced options

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv,
    CipherFileOption advOptions
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 16 bytes (128 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes. Use null/Nothing for ECB mode or when using CipherFileOption.PrefixIV option

advOptions CipherFileOption

Advanced options. See CipherFileOption.

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Aes128 Class
CryptoSysAPI Namespace

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

Encrypt a file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 16 bytes (128 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Aes128 Class
CryptoSysAPI Namespace

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

Encrypt a file passing key and IV as hex strings

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

keyHex String

Hex-encoded key of exact length

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV or "" for ECB mode

Return Value

Int32
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.

See Also

Aes128 Class
CryptoSysAPI Namespace

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

Encrypt a file with advanced options

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv,
    CipherFileOption advOptions
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 16 bytes (128 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

advOptions CipherFileOption

Advanced options. See CipherFileOption.

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Aes128 Class
CryptoSysAPI Namespace

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

Initializes with key, mode and IV ready to start decrypting

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

public int InitDecrypt(
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

key Byte[]

Key of exactly 16 bytes (128 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

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

See Also

Aes128 Class
CryptoSysAPI Namespace

Aes128.InitDecrypt(String, Mode, String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

public int InitDecrypt(
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

keyHex String

Key in hex-encoded format

mode Mode

Cipher mode

ivHex String

IV in hex-encoded format

Return Value

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

See Also

Aes128 Class
CryptoSysAPI Namespace

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

Initializes with key, mode and IV ready to start encrypting

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

public int InitEncrypt(
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

key Byte[]

Key of exactly 16 bytes (128 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

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

See Also

Aes128 Class
CryptoSysAPI Namespace

Aes128.InitEncrypt(String, Mode, String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

public int InitEncrypt(
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

keyHex String

Key in hex-encoded format

mode Mode

Cipher mode

ivHex String

IV in hex-encoded format

Return Value

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

See Also

Aes128 Class
CryptoSysAPI Namespace

Aes128.Instance Method

Create the one and only instance

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static Aes128 Instance()

Return Value

Aes128
Single instance to class

Remarks

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

See Also

Aes128 Class
CryptoSysAPI Namespace

Aes128.Pad(Byte[]) Method

Pads byte array to correct length for ECB and CBC encryption

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

public static byte[] Pad(
    byte[] data
)

Parameters

data Byte[]

data to be padded

Return Value

Byte[]
padded data in byte array

Remarks

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

See Also

Aes128 Class
CryptoSysAPI Namespace

Aes128.Pad(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

public static string Pad(
    string dataHex
)

Parameters

dataHex String

hex-encoded data to be padded

Return Value

String
padded data in hex-encoded string

Remarks

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

See Also

Aes128 Class
CryptoSysAPI Namespace

Aes128.Unpad(Byte[]) Method

Removes the padding from an encryption block

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block

Syntax

public static byte[] Unpad(
    byte[] data
)

Parameters

data Byte[]

padded data

Return Value

Byte[]
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.

See Also

Aes128 Class
CryptoSysAPI Namespace

Aes128.Unpad(String) Method

Removes the padding from a hex-encoded encryption block

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block

Syntax

public static string Unpad(
    string dataHex
)

Parameters

dataHex String

hex-encoded padded data

Return Value

String
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.

See Also

Aes128 Class
CryptoSysAPI Namespace

Aes128.Update(Byte[]) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction
Update(String) Transform hex string data with previously initialized key, mode and direction

Syntax

public byte[] Update(
    byte[] data
)

Parameters

data Byte[]

input data in byte array

Return Value

Byte[]
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)

See Also

Aes128 Class
CryptoSysAPI Namespace

Aes128.Update(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction
Update(String) Transform hex string data with previously initialized key, mode and direction

Syntax

public string Update(
    string data
)

Parameters

data String

hex-encoded input data

Return Value

String
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)

See Also

Aes128 Class
CryptoSysAPI Namespace

Aes128.BlockSize Field

Block size in bytes

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public const int BlockSize = 16

Field Value

Int32

See Also

Aes128 Class
CryptoSysAPI Namespace

Aes192 Class

Advanced Encryption Standard (AES) with 192-bit key

Inheritance Hierarchy

System.Object
CryptoSysAPI.Aes192

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Aes192 : IDisposable

The Aes192 type exposes the following members.

Properties

Name Description
ErrCode Last error code (for Init and Update methods only)

Methods

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string
Dispose Dispose of this object and clear any key schedules
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting
Instance Create the one and only instance
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction
Update(String) Transform hex string data with previously initialized key, mode and direction

Fields

Name Description
BlockSize Block size in bytes

See Also

CryptoSysAPI Namespace

Aes192.ErrCode Property

Last error code (for Init and Update methods only)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int ErrCode { get; }

Property Value

Int32

See Also

Aes192 Class
CryptoSysAPI Namespace

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

Decrypt data in byte array

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static byte[] Decrypt(
    byte[] input,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

input Byte[]

Input data

key Byte[]

Key of exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Byte[]
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)

See Also

Aes192 Class
CryptoSysAPI Namespace

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

Decrypt hex-encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static string Decrypt(
    string inputHex,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

inputHex String

Hex-encoded input data

keyHex String

Hex-encoded key representing exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV representing exactly 16 bytes or "" for ECB mode

Return Value

String
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)

See Also

Aes192 Class
CryptoSysAPI Namespace

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

Decrypt encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static string Decrypt(
    string inputStr,
    string keyStr,
    Mode mode,
    string ivStr,
    EncodingBase encodingBase
)

Parameters

inputStr String

Encoded input data

keyStr String

Encoded key representing exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

ivStr String

Encoded IV representing exactly 16 bytes or "" for ECB mode

encodingBase EncodingBase

Type of encoding used

Return Value

String
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)

See Also

Aes192 Class
CryptoSysAPI Namespace

Aes192.Dispose Method

Dispose of this object and clear any key schedules

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public void Dispose()

Implements

IDisposable.Dispose()

See Also

Aes192 Class
CryptoSysAPI Namespace

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

Encrypt data in byte array

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static byte[] Encrypt(
    byte[] input,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

input Byte[]

Input data

key Byte[]

Key of exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Byte[]
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)

See Also

Aes192 Class
CryptoSysAPI Namespace

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

Encrypt hex-encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static string Encrypt(
    string inputHex,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

inputHex String

Hex-encoded input data

keyHex String

Hex-encoded key representing exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV representing exactly 16 bytes or "" for ECB mode

Return Value

String
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)

See Also

Aes192 Class
CryptoSysAPI Namespace

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

Encrypt encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static string Encrypt(
    string inputStr,
    string keyStr,
    Mode mode,
    string ivStr,
    EncodingBase encodingBase
)

Parameters

inputStr String

Encoded input data

keyStr String

Encoded key representing exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

ivStr String

Encoded IV representing exactly 16 bytes or "" for ECB mode

encodingBase EncodingBase

Type of encoding used

Return Value

String
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)

See Also

Aes192 Class
CryptoSysAPI Namespace

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

Decrypt a file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Aes192 Class
CryptoSysAPI Namespace

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

Decrypt a file passing key and IV as hex strings

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

keyHex String

Hex-encoded key of exact length

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV or "" for ECB mode

Return Value

Int32
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.

See Also

Aes192 Class
CryptoSysAPI Namespace

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

Decrypt a file with advanced options

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv,
    CipherFileOption advOptions
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes. Use null/Nothing for ECB mode or when using CipherFileOption.PrefixIV option

advOptions CipherFileOption

Advanced options. See CipherFileOption.

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Aes192 Class
CryptoSysAPI Namespace

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

Encrypt a file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Aes192 Class
CryptoSysAPI Namespace

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

Encrypt a file passing key and IV as hex strings

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

keyHex String

Hex-encoded key of exact length

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV or "" for ECB mode

Return Value

Int32
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.

See Also

Aes192 Class
CryptoSysAPI Namespace

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

Encrypt a file with advanced options

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv,
    CipherFileOption advOptions
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

advOptions CipherFileOption

Advanced options. See CipherFileOption.

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Aes192 Class
CryptoSysAPI Namespace

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

Initializes with key, mode and IV ready to start decrypting

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

public int InitDecrypt(
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

key Byte[]

Key of exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

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

See Also

Aes192 Class
CryptoSysAPI Namespace

Aes192.InitDecrypt(String, Mode, String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

public int InitDecrypt(
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

keyHex String

Key in hex-encoded format

mode Mode

Cipher mode

ivHex String

IV in hex-encoded format

Return Value

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

See Also

Aes192 Class
CryptoSysAPI Namespace

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

Initializes with key, mode and IV ready to start encrypting

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

public int InitEncrypt(
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

key Byte[]

Key of exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

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

See Also

Aes192 Class
CryptoSysAPI Namespace

Aes192.InitEncrypt(String, Mode, String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

public int InitEncrypt(
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

keyHex String

Key in hex-encoded format

mode Mode

Cipher mode

ivHex String

IV in hex-encoded format

Return Value

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

See Also

Aes192 Class
CryptoSysAPI Namespace

Aes192.Instance Method

Create the one and only instance

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static Aes192 Instance()

Return Value

Aes192
Single instance to class

Remarks

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

See Also

Aes192 Class
CryptoSysAPI Namespace

Aes192.Pad(Byte[]) Method

Pads byte array to correct length for ECB and CBC encryption

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

public static byte[] Pad(
    byte[] data
)

Parameters

data Byte[]

data to be padded

Return Value

Byte[]
padded data in byte array

Remarks

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

See Also

Aes192 Class
CryptoSysAPI Namespace

Aes192.Pad(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

public static string Pad(
    string dataHex
)

Parameters

dataHex String

hex-encoded data to be padded

Return Value

String
padded data in hex-encoded string

Remarks

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

See Also

Aes192 Class
CryptoSysAPI Namespace

Aes192.Unpad(Byte[]) Method

Removes the padding from an encryption block

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block

Syntax

public static byte[] Unpad(
    byte[] data
)

Parameters

data Byte[]

padded data

Return Value

Byte[]
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.

See Also

Aes192 Class
CryptoSysAPI Namespace

Aes192.Unpad(String) Method

Removes the padding from a hex-encoded encryption block

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block

Syntax

public static string Unpad(
    string dataHex
)

Parameters

dataHex String

hex-encoded padded data

Return Value

String
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.

See Also

Aes192 Class
CryptoSysAPI Namespace

Aes192.Update(Byte[]) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction
Update(String) Transform hex string data with previously initialized key, mode and direction

Syntax

public byte[] Update(
    byte[] data
)

Parameters

data Byte[]

input data in byte array

Return Value

Byte[]
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)

See Also

Aes192 Class
CryptoSysAPI Namespace

Aes192.Update(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction
Update(String) Transform hex string data with previously initialized key, mode and direction

Syntax

public string Update(
    string data
)

Parameters

data String

hex-encoded input data

Return Value

String
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)

See Also

Aes192 Class
CryptoSysAPI Namespace

Aes192.BlockSize Field

Block size in bytes

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public const int BlockSize = 16

Field Value

Int32

See Also

Aes192 Class
CryptoSysAPI Namespace

Aes256 Class

Advanced Encryption Standard (AES) with 256-bit key

Inheritance Hierarchy

System.Object
CryptoSysAPI.Aes256

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Aes256 : IDisposable

The Aes256 type exposes the following members.

Properties

Name Description
ErrCode Last error code (for Init and Update methods only)

Methods

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string
Dispose Dispose of this object and clear any key schedules
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting
Instance Create the one and only instance
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction
Update(String) Transform hex string data with previously initialized key, mode and direction

Fields

Name Description
BlockSize Block size in bytes

See Also

CryptoSysAPI Namespace

Aes256.ErrCode Property

Last error code (for Init and Update methods only)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int ErrCode { get; }

Property Value

Int32

See Also

Aes256 Class
CryptoSysAPI Namespace

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

Decrypt data in byte array

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static byte[] Decrypt(
    byte[] input,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

input Byte[]

Input data

key Byte[]

Key of exactly 32 bytes (256 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Byte[]
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)

See Also

Aes256 Class
CryptoSysAPI Namespace

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

Decrypt hex-encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static string Decrypt(
    string inputHex,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

inputHex String

Hex-encoded input data

keyHex String

Hex-encoded key representing exactly 32 bytes (256 bits)

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV representing exactly 16 bytes or "" for ECB mode

Return Value

String
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)

See Also

Aes256 Class
CryptoSysAPI Namespace

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

Decrypt encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static string Decrypt(
    string inputStr,
    string keyStr,
    Mode mode,
    string ivStr,
    EncodingBase encodingBase
)

Parameters

inputStr String

Encoded input data

keyStr String

Encoded key representing exactly 32 bytes (256 bits)

mode Mode

Cipher Mode

ivStr String

Encoded IV representing exactly 16 bytes or "" for ECB mode

encodingBase EncodingBase

Type of encoding used

Return Value

String
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)

See Also

Aes256 Class
CryptoSysAPI Namespace

Aes256.Dispose Method

Dispose of this object and clear any key schedules

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public void Dispose()

Implements

IDisposable.Dispose()

See Also

Aes256 Class
CryptoSysAPI Namespace

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

Encrypt data in byte array

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static byte[] Encrypt(
    byte[] input,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

input Byte[]

Input data

key Byte[]

Key of exactly 32 bytes (256 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

Byte[]
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)

See Also

Aes256 Class
CryptoSysAPI Namespace

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

Encrypt hex-encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static string Encrypt(
    string inputHex,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

inputHex String

Hex-encoded input data

keyHex String

Hex-encoded key representing exactly 32 bytes (256 bits)

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV representing exactly 16 bytes or "" for ECB mode

Return Value

String
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)

See Also

Aes256 Class
CryptoSysAPI Namespace

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

Encrypt encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static string Encrypt(
    string inputStr,
    string keyStr,
    Mode mode,
    string ivStr,
    EncodingBase encodingBase
)

Parameters

inputStr String

Encoded input data

keyStr String

Encoded key representing exactly 32 bytes (256 bits)

mode Mode

Cipher Mode

ivStr String

Encoded IV representing exactly 16 bytes or "" for ECB mode

encodingBase EncodingBase

Type of encoding used

Return Value

String
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)

See Also

Aes256 Class
CryptoSysAPI Namespace

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

Decrypt a file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 32 bytes (256 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Aes256 Class
CryptoSysAPI Namespace

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

Decrypt a file passing key and IV as hex strings

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

keyHex String

Hex-encoded key of exact length

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV or "" for ECB mode

Return Value

Int32
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.

See Also

Aes256 Class
CryptoSysAPI Namespace

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

Decrypt a file with advanced options

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv,
    CipherFileOption advOptions
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 32 bytes (256 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes. Use null/Nothing for ECB mode or when using CipherFileOption.PrefixIV option

advOptions CipherFileOption

Advanced options. See CipherFileOption.

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Aes256 Class
CryptoSysAPI Namespace

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

Encrypt a file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 32 bytes (256 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Aes256 Class
CryptoSysAPI Namespace

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

Encrypt a file passing key and IV as hex strings

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

keyHex String

Hex-encoded key of exact length

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV or "" for ECB mode

Return Value

Int32
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.

See Also

Aes256 Class
CryptoSysAPI Namespace

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

Encrypt a file with advanced options

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv,
    CipherFileOption advOptions
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 32 bytes (256 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

advOptions CipherFileOption

Advanced options. See CipherFileOption.

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Aes256 Class
CryptoSysAPI Namespace

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

Initializes with key, mode and IV ready to start decrypting

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

public int InitDecrypt(
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

key Byte[]

Key of exactly 32 bytes (256 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

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

See Also

Aes256 Class
CryptoSysAPI Namespace

Aes256.InitDecrypt(String, Mode, String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

public int InitDecrypt(
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

keyHex String

Key in hex-encoded format

mode Mode

Cipher mode

ivHex String

IV in hex-encoded format

Return Value

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

See Also

Aes256 Class
CryptoSysAPI Namespace

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

Initializes with key, mode and IV ready to start encrypting

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

public int InitEncrypt(
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

key Byte[]

Key of exactly 32 bytes (256 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 16 bytes or null/Nothing for ECB mode

Return Value

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

See Also

Aes256 Class
CryptoSysAPI Namespace

Aes256.InitEncrypt(String, Mode, String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

public int InitEncrypt(
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

keyHex String

Key in hex-encoded format

mode Mode

Cipher mode

ivHex String

IV in hex-encoded format

Return Value

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

See Also

Aes256 Class
CryptoSysAPI Namespace

Aes256.Instance Method

Create the one and only instance

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static Aes256 Instance()

Return Value

Aes256
Single instance to class

Remarks

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

See Also

Aes256 Class
CryptoSysAPI Namespace

Aes256.Pad(Byte[]) Method

Pads byte array to correct length for ECB and CBC encryption

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

public static byte[] Pad(
    byte[] data
)

Parameters

data Byte[]

data to be padded

Return Value

Byte[]
padded data in byte array

Remarks

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

See Also

Aes256 Class
CryptoSysAPI Namespace

Aes256.Pad(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

public static string Pad(
    string dataHex
)

Parameters

dataHex String

hex-encoded data to be padded

Return Value

String
padded data in hex-encoded string

Remarks

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

See Also

Aes256 Class
CryptoSysAPI Namespace

Aes256.Unpad(Byte[]) Method

Removes the padding from an encryption block

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block

Syntax

public static byte[] Unpad(
    byte[] data
)

Parameters

data Byte[]

padded data

Return Value

Byte[]
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.

See Also

Aes256 Class
CryptoSysAPI Namespace

Aes256.Unpad(String) Method

Removes the padding from a hex-encoded encryption block

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block

Syntax

public static string Unpad(
    string dataHex
)

Parameters

dataHex String

hex-encoded padded data

Return Value

String
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.

See Also

Aes256 Class
CryptoSysAPI Namespace

Aes256.Update(Byte[]) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction
Update(String) Transform hex string data with previously initialized key, mode and direction

Syntax

public byte[] Update(
    byte[] data
)

Parameters

data Byte[]

input data in byte array

Return Value

Byte[]
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)

See Also

Aes256 Class
CryptoSysAPI Namespace

Aes256.Update(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction
Update(String) Transform hex string data with previously initialized key, mode and direction

Syntax

public string Update(
    string data
)

Parameters

data String

hex-encoded input data

Return Value

String
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)

See Also

Aes256 Class
CryptoSysAPI Namespace

Aes256.BlockSize Field

Block size in bytes

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public const int BlockSize = 16

Field Value

Int32

See Also

Aes256 Class
CryptoSysAPI Namespace

Blowfish Class

Blowfish cipher algorithm

Inheritance Hierarchy

System.Object
CryptoSysAPI.Blowfish

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Blowfish : IDisposable

The Blowfish type exposes the following members.

Properties

Name Description
ErrCode Last error code (for Init and Update methods only)

Methods

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string
Dispose Dispose of this object and clear any key schedules
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting
Instance Create the one and only instance
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction
Update(String) Transform hex string data with previously initialized key, mode and direction

Fields

Name Description
BlockSize Block size in bytes

See Also

CryptoSysAPI Namespace

Blowfish.ErrCode Property

Last error code (for Init and Update methods only)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int ErrCode { get; }

Property Value

Int32

See Also

Blowfish Class
CryptoSysAPI Namespace

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

Decrypt data in byte array

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static byte[] Decrypt(
    byte[] input,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

input Byte[]

Input data

key Byte[]

Key of length between 1 and 56 bytes (448 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Byte[]
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)

See Also

Blowfish Class
CryptoSysAPI Namespace

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

Decrypt hex-encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static string Decrypt(
    string inputHex,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

inputHex String

Hex-encoded input data

keyHex String

Hex-encoded key

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV representing exactly 8 bytes or "" for ECB mode

Return Value

String
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)

See Also

Blowfish Class
CryptoSysAPI Namespace

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

Decrypt encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static string Decrypt(
    string inputStr,
    string keyStr,
    Mode mode,
    string ivStr,
    EncodingBase encodingBase
)

Parameters

inputStr String

Encoded input data

keyStr String

Encoded key

mode Mode

Cipher Mode

ivStr String

Encoded IV representing exactly 8 bytes or "" for ECB mode

encodingBase EncodingBase

Type of encoding used

Return Value

String
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)

See Also

Blowfish Class
CryptoSysAPI Namespace

Blowfish.Dispose Method

Dispose of this object and clear any key schedules

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public void Dispose()

Implements

IDisposable.Dispose()

See Also

Blowfish Class
CryptoSysAPI Namespace

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

Encrypt data in byte array

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static byte[] Encrypt(
    byte[] input,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

input Byte[]

Input data

key Byte[]

Key of length between 1 and 56 bytes (448 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Byte[]
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)

See Also

Blowfish Class
CryptoSysAPI Namespace

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

Encrypt hex-encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static string Encrypt(
    string inputHex,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

inputHex String

Hex-encoded input data

keyHex String

Hex-encoded key

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV representing exactly 8 bytes or "" for ECB mode

Return Value

String
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)

See Also

Blowfish Class
CryptoSysAPI Namespace

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

Encrypt encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static string Encrypt(
    string inputStr,
    string keyStr,
    Mode mode,
    string ivStr,
    EncodingBase encodingBase
)

Parameters

inputStr String

Encoded input data

keyStr String

Encoded key

mode Mode

Cipher Mode

ivStr String

Encoded IV representing exactly 8 bytes or "" for ECB mode

encodingBase EncodingBase

Type of encoding used

Return Value

String
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)

See Also

Blowfish Class
CryptoSysAPI Namespace

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

Decrypt a file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of length between 1 and 56 bytes (448 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Blowfish Class
CryptoSysAPI Namespace

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

Decrypt a file passing key and IV as hex strings

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

keyHex String

Hex-encoded key

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV or "" for ECB mode

Return Value

Int32
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.

See Also

Blowfish Class
CryptoSysAPI Namespace

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

Decrypt a file with advanced options

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv,
    CipherFileOption advOptions
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of length between 1 and 56 bytes (448 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes. Use null/Nothing for ECB mode or when using CipherFileOption.PrefixIV option

advOptions CipherFileOption

Advanced options. See CipherFileOption.

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Blowfish Class
CryptoSysAPI Namespace

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

Encrypt a file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of length between 1 and 56 bytes (448 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Blowfish Class
CryptoSysAPI Namespace

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

Encrypt a file passing key and IV as hex strings

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

keyHex String

Hex-encoded key

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV or "" for ECB mode

Return Value

Int32
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.

See Also

Blowfish Class
CryptoSysAPI Namespace

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

Encrypt a file with advanced options

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv,
    CipherFileOption advOptions
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of length between 1 and 56 bytes (448 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

advOptions CipherFileOption

Advanced options. See CipherFileOption.

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Blowfish Class
CryptoSysAPI Namespace

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

Initializes with key, mode and IV ready to start decrypting

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

public int InitDecrypt(
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

key Byte[]

Key of length between 1 and 56 bytes (448 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

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

See Also

Blowfish Class
CryptoSysAPI Namespace

Blowfish.InitDecrypt(String, Mode, String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

public int InitDecrypt(
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

keyHex String

Key in hex-encoded format

mode Mode

Cipher mode

ivHex String

IV in hex-encoded format

Return Value

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

See Also

Blowfish Class
CryptoSysAPI Namespace

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

Initializes with key, mode and IV ready to start encrypting

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

public int InitEncrypt(
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

key Byte[]

Key of length between 1 and 56 bytes (448 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

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

See Also

Blowfish Class
CryptoSysAPI Namespace

Blowfish.InitEncrypt(String, Mode, String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

public int InitEncrypt(
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

keyHex String

Key in hex-encoded format

mode Mode

Cipher mode

ivHex String

IV in hex-encoded format

Return Value

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

See Also

Blowfish Class
CryptoSysAPI Namespace

Blowfish.Instance Method

Create the one and only instance

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static Blowfish Instance()

Return Value

Blowfish
Single instance to class

See Also

Blowfish Class
CryptoSysAPI Namespace

Blowfish.Pad(Byte[]) Method

Pads byte array to correct length for ECB and CBC encryption

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

public static byte[] Pad(
    byte[] data
)

Parameters

data Byte[]

data to be padded

Return Value

Byte[]
padded data in byte array

Remarks

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

See Also

Blowfish Class
CryptoSysAPI Namespace

Blowfish.Pad(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

public static string Pad(
    string dataHex
)

Parameters

dataHex String

hex-encoded data to be padded

Return Value

String
padded data in hex-encoded string

Remarks

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

See Also

Blowfish Class
CryptoSysAPI Namespace

Blowfish.Unpad(Byte[]) Method

Removes the padding from an encryption block

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block

Syntax

public static byte[] Unpad(
    byte[] data
)

Parameters

data Byte[]

padded data

Return Value

Byte[]
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.

See Also

Blowfish Class
CryptoSysAPI Namespace

Blowfish.Unpad(String) Method

Removes the padding from a hex-encoded encryption block

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block

Syntax

public static string Unpad(
    string dataHex
)

Parameters

dataHex String

hex-encoded padded data

Return Value

String
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.

See Also

Blowfish Class
CryptoSysAPI Namespace

Blowfish.Update(Byte[]) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction
Update(String) Transform hex string data with previously initialized key, mode and direction

Syntax

public byte[] Update(
    byte[] data
)

Parameters

data Byte[]

input data in byte array

Return Value

Byte[]
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)

See Also

Blowfish Class
CryptoSysAPI Namespace

Blowfish.Update(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction
Update(String) Transform hex string data with previously initialized key, mode and direction

Syntax

public string Update(
    string data
)

Parameters

data String

hex-encoded input data

Return Value

String
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)

See Also

Blowfish Class
CryptoSysAPI Namespace

Blowfish.BlockSize Field

Block size in bytes

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public const int BlockSize = 8

Field Value

Int32

See Also

Blowfish Class
CryptoSysAPI Namespace

Cipher Class

Block cipher utilities

Inheritance Hierarchy

System.Object
CryptoSysAPI.Cipher

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Cipher

The Cipher type exposes the following members.

Properties

Name Description
ErrCode Last error code (for Init, Update and Final object methods only)

Methods

Name Description
BlockBytes Return the block size in bytes for a given cipher algorithm
Decrypt(Byte[], Byte[], Byte[], CipherAlgorithm, Mode, Padding, Cipher.Opts) Decrypt data in a byte array using the specified block cipher algorithm, mode and padding.
Decrypt(String, String, String, CipherAlgorithm, Mode, Padding, Cipher.Opts) Decrypt hex-encoded data using specified block cipher algorithm, mode and padding.
Dispose Dispose of this object and clear any stored data.
Encrypt(Byte[], Byte[], Byte[], CipherAlgorithm, Mode, Padding, Cipher.Opts) Encrypt data in a byte array using the specified block cipher algorithm, mode and padding.
Encrypt(String, String, String, CipherAlgorithm, Mode, Padding, Cipher.Opts) Encrypt hex-encoded data using specified block cipher algorithm, mode and padding.
FileDecrypt Decrypt a file with block cipher
FileEncrypt Encrypt a file with block cipher
InitDecrypt(Byte[], Byte[], CipherAlgorithm, Mode) Initializes with key, iv, algorithm and mode ready to start decrypting with repeated update operations.
InitDecrypt(String, String, CipherAlgorithm, Mode) Initializes with hex-encoded key, iv, algorithm and mode ready to start decrypting with repeated update operations.
InitEncrypt(Byte[], Byte[], CipherAlgorithm, Mode) Initializes with key, iv, algorithm and mode ready to start encrypting with repeated update operations.
InitEncrypt(String, String, CipherAlgorithm, Mode) Initializes with hex-encoded key, iv, algorithm and mode ready to start encrypting with repeated update operations.
Instance Create the one and only instance
KeyBytes Return the key size in bytes for a given cipher algorithm
KeyUnwrap Unwraps (decrypts) key material with a key-encryption key
KeyWrap Wraps (encrypts) key material with a key-encryption key
Pad(Byte[], CipherAlgorithm, Padding) Pad byte array for block cipher.
Pad(String, CipherAlgorithm, Padding) Pads hex-encoded string for block cipher.
Unpad(Byte[], CipherAlgorithm, Padding) Remove padding from an encryption block.
Unpad(String, CipherAlgorithm, Padding) Remove padding from a hex-encoded encryption block.
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction.
Update(String) Transform hex string data with previously initialized key, mode and direction

See Also

CryptoSysAPI Namespace

Cipher.ErrCode Property

Last error code (for Init, Update and Final object methods only)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int ErrCode { get; }

Property Value

Int32

See Also

Cipher Class
CryptoSysAPI Namespace

Cipher.BlockBytes Method

Return the block size in bytes for a given cipher algorithm

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static int BlockBytes(
    CipherAlgorithm alg
)

Parameters

alg CipherAlgorithm

Cipher algorithm

Return Value

Int32
Block size in bytes

See Also

Cipher Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Byte[], CipherAlgorithm, Mode, Padding, Cipher.Opts) Decrypt data in a byte array using the specified block cipher algorithm, mode and padding.
Decrypt(String, String, String, CipherAlgorithm, Mode, Padding, Cipher.Opts) Decrypt hex-encoded data using specified block cipher algorithm, mode and padding.

Syntax

public static byte[] Decrypt(
    byte[] input,
    byte[] key,
    byte[] iv,
    CipherAlgorithm cipherAlg,
    Mode mode,
    Padding pad,
    Cipher.Opts opts = Cipher.Opts.Default
)

Parameters

input Byte[]

Input data to be decrypted

key Byte[]

Key of exact length for block cipher algorithm

iv Byte[]

Initialization Vector (IV) of exactly the block size or null for ECB mode, if not provided in input.

cipherAlg CipherAlgorithm

Cipher algorithm

mode Mode

Cipher mode

pad Padding

Padding method to use

opts Cipher.Opts (Optional)

Advanced options (optional). Use Cipher.Opts.PrefixIV to expect the IV to be prepended at the start of the input.

Return Value

Byte[]
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.

See Also

Cipher Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Byte[], CipherAlgorithm, Mode, Padding, Cipher.Opts) Decrypt data in a byte array using the specified block cipher algorithm, mode and padding.
Decrypt(String, String, String, CipherAlgorithm, Mode, Padding, Cipher.Opts) Decrypt hex-encoded data using specified block cipher algorithm, mode and padding.

Syntax

public static string Decrypt(
    string inputHex,
    string keyHex,
    string ivHex,
    CipherAlgorithm cipherAlg,
    Mode mode,
    Padding pad,
    Cipher.Opts opts = Cipher.Opts.Default
)

Parameters

inputHex String

Hex-encoded input data

keyHex String

Hex-encoded key representing exact key length

ivHex String

Hex-encoded IV representing exact block length or "" for ECB mode

cipherAlg CipherAlgorithm

Cipher Algorithm

mode Mode

Cipher Mode

pad Padding

Padding method to use

opts Cipher.Opts (Optional)

Advanced options (optional). Use Cipher.Opts.PrefixIV to prepend the IV to the output.

Return Value

String
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.

See Also

Cipher Class
CryptoSysAPI Namespace

Cipher.Dispose Method

Dispose of this object and clear any stored data.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public void Dispose()

See Also

Cipher Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Byte[], CipherAlgorithm, Mode, Padding, Cipher.Opts) Encrypt data in a byte array using the specified block cipher algorithm, mode and padding.
Encrypt(String, String, String, CipherAlgorithm, Mode, Padding, Cipher.Opts) Encrypt hex-encoded data using specified block cipher algorithm, mode and padding.

Syntax

public static byte[] Encrypt(
    byte[] input,
    byte[] key,
    byte[] iv,
    CipherAlgorithm cipherAlg,
    Mode mode,
    Padding pad,
    Cipher.Opts opts = Cipher.Opts.Default
)

Parameters

input Byte[]

Input data to be encrypted

key Byte[]

Key of exact length for block cipher algorithm

iv Byte[]

Initialization Vector (IV) of exactly the block size or null for ECB mode, if not provided in input.

cipherAlg CipherAlgorithm

Cipher algorithm

mode Mode

Cipher mode

pad Padding

Padding method to use

opts Cipher.Opts (Optional)

Advanced options (optional). Use Cipher.Opts.PrefixIV to prepend the IV to the output.

Return Value

Byte[]
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.

See Also

Cipher Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Byte[], CipherAlgorithm, Mode, Padding, Cipher.Opts) Encrypt data in a byte array using the specified block cipher algorithm, mode and padding.
Encrypt(String, String, String, CipherAlgorithm, Mode, Padding, Cipher.Opts) Encrypt hex-encoded data using specified block cipher algorithm, mode and padding.

Syntax

public static string Encrypt(
    string inputHex,
    string keyHex,
    string ivHex,
    CipherAlgorithm cipherAlg,
    Mode mode,
    Padding pad,
    Cipher.Opts opts = Cipher.Opts.Default
)

Parameters

inputHex String

Hex-encoded input data

keyHex String

Hex-encoded key representing exact key length

ivHex String

Hex-encoded IV representing exact block length or "" for ECB mode

cipherAlg CipherAlgorithm

Cipher Algorithm

mode Mode

Cipher Mode

pad Padding

Padding method to use

opts Cipher.Opts (Optional)

Advanced options (optional). Use Cipher.Opts.PrefixIV to prepend the IV to the output.

Return Value

String
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.

See Also

Cipher Class
CryptoSysAPI Namespace

Cipher.FileDecrypt Method

Decrypt a file with block cipher

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    byte[] iv,
    CipherAlgorithm cipherAlg,
    Mode mode,
    Padding pad,
    Cipher.Opts opts
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of of exact length for block cipher algorithm

iv Byte[]

Initialization Vector (IV) of exactly the block size or null for ECB mode

cipherAlg CipherAlgorithm

Cipher Algorithm

mode Mode

Cipher Mode

pad Padding

Padding method to use (ECB and CBC modes only)

opts Cipher.Opts

Advanced options

Return Value

Int32
0 if successful or nonzero error code

Remarks

fileOut and fileIn must not be the same

See Also

Cipher Class
CryptoSysAPI Namespace

Cipher.FileEncrypt Method

Encrypt a file with block cipher

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    byte[] iv,
    CipherAlgorithm cipherAlg,
    Mode mode,
    Padding pad,
    Cipher.Opts opts
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of of exact length for block cipher algorithm

iv Byte[]

Initialization Vector (IV) of exactly the block size or null for ECB mode

cipherAlg CipherAlgorithm

Cipher Algorithm

mode Mode

Cipher Mode

pad Padding

Padding method to use (ECB and CBC modes only)

opts Cipher.Opts

Advanced options

Return Value

Int32
0 if successful or nonzero error code

Remarks

fileOut and fileIn must not be the same

See Also

Cipher Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitDecrypt(Byte[], Byte[], CipherAlgorithm, Mode) Initializes with key, iv, algorithm and mode ready to start decrypting with repeated update operations.
InitDecrypt(String, String, CipherAlgorithm, Mode) Initializes with hex-encoded key, iv, algorithm and mode ready to start decrypting with repeated update operations.

Syntax

public bool InitDecrypt(
    byte[] key,
    byte[] iv,
    CipherAlgorithm cipherAlg,
    Mode mode
)

Parameters

key Byte[]

Key of exact length for block cipher algorithm.

iv Byte[]

Initialization Vector (IV) of exactly the block size or null/Nothing for ECB mode.

cipherAlg CipherAlgorithm

Cipher algorithm

mode Mode

Cipher mode

Return Value

Boolean
True if successful, False if failed.

See Also

Cipher Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitDecrypt(Byte[], Byte[], CipherAlgorithm, Mode) Initializes with key, iv, algorithm and mode ready to start decrypting with repeated update operations.
InitDecrypt(String, String, CipherAlgorithm, Mode) Initializes with hex-encoded key, iv, algorithm and mode ready to start decrypting with repeated update operations.

Syntax

public bool InitDecrypt(
    string keyHex,
    string ivHex,
    CipherAlgorithm cipherAlg,
    Mode mode
)

Parameters

keyHex String

Hex-encoded key of exact length for block cipher algorithm.

ivHex String

Hex-encoded Initialization Vector (IV) of exactly the block size or "" for ECB mode.

cipherAlg CipherAlgorithm

Cipher algorithm

mode Mode

Cipher mode

Return Value

Boolean
True if successful, False if failed.

See Also

Cipher Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitEncrypt(Byte[], Byte[], CipherAlgorithm, Mode) Initializes with key, iv, algorithm and mode ready to start encrypting with repeated update operations.
InitEncrypt(String, String, CipherAlgorithm, Mode) Initializes with hex-encoded key, iv, algorithm and mode ready to start encrypting with repeated update operations.

Syntax

public bool InitEncrypt(
    byte[] key,
    byte[] iv,
    CipherAlgorithm cipherAlg,
    Mode mode
)

Parameters

key Byte[]

Key of exact length for block cipher algorithm.

iv Byte[]

Initialization Vector (IV) of exactly the block size or null/Nothing for ECB mode.

cipherAlg CipherAlgorithm

Cipher algorithm

mode Mode

Cipher mode

Return Value

Boolean
True if successful, False if failed.

See Also

Cipher Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitEncrypt(Byte[], Byte[], CipherAlgorithm, Mode) Initializes with key, iv, algorithm and mode ready to start encrypting with repeated update operations.
InitEncrypt(String, String, CipherAlgorithm, Mode) Initializes with hex-encoded key, iv, algorithm and mode ready to start encrypting with repeated update operations.

Syntax

public bool InitEncrypt(
    string keyHex,
    string ivHex,
    CipherAlgorithm cipherAlg,
    Mode mode
)

Parameters

keyHex String

Hex-encoded key of exact length for block cipher algorithm.

ivHex String

Hex-encoded Initialization Vector (IV) of exactly the block size or "" for ECB mode.

cipherAlg CipherAlgorithm

Cipher algorithm

mode Mode

Cipher mode

Return Value

Boolean
True if successful, False if failed.

See Also

Cipher Class
CryptoSysAPI Namespace

Cipher.Instance Method

Create the one and only instance

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static Cipher Instance()

Return Value

Cipher
Single instance to class

See Also

Cipher Class
CryptoSysAPI Namespace

Cipher.KeyBytes Method

Return the key size in bytes for a given cipher algorithm

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static int KeyBytes(
    CipherAlgorithm alg
)

Parameters

alg CipherAlgorithm

Cipher algorithm

Return Value

Int32
Key size in bytes

See Also

Cipher Class
CryptoSysAPI Namespace

Cipher.KeyUnwrap Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] KeyUnwrap(
    byte[] data,
    byte[] kek,
    CipherAlgorithm cipherAlg
)

Parameters

data Byte[]

Wrapped key

kek Byte[]

Key encryption key

cipherAlg CipherAlgorithm

Block cipher to use for wrapping

Return Value

Byte[]
Unwrapped key material (or empty array on error)

See Also

Cipher Class
CryptoSysAPI Namespace

Cipher.KeyWrap Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] KeyWrap(
    byte[] data,
    byte[] kek,
    CipherAlgorithm cipherAlg
)

Parameters

data Byte[]

Key material to be wrapped

kek Byte[]

Key encryption key

cipherAlg CipherAlgorithm

Block cipher to use for wrapping

Return Value

Byte[]
Wrapped key (or empty array on error)

See Also

Cipher Class
CryptoSysAPI Namespace

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

Pad byte array for block cipher.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Pad(Byte[], CipherAlgorithm, Padding) Pad byte array for block cipher.
Pad(String, CipherAlgorithm, Padding) Pads hex-encoded string for block cipher.

Syntax

public static byte[] Pad(
    byte[] input,
    CipherAlgorithm cipherAlg,
    Padding pad
)

Parameters

input Byte[]

data to be padded

cipherAlg CipherAlgorithm

Block cipher being used

pad Padding

Padding method to use

Return Value

Byte[]
Padded data in byte array

See Also

Cipher Class
CryptoSysAPI Namespace

Cipher.Pad(String, CipherAlgorithm, Padding) Method

Pads hex-encoded string for block cipher.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Pad(Byte[], CipherAlgorithm, Padding) Pad byte array for block cipher.
Pad(String, CipherAlgorithm, Padding) Pads hex-encoded string for block cipher.

Syntax

public static string Pad(
    string inputHex,
    CipherAlgorithm cipherAlg,
    Padding pad
)

Parameters

inputHex String

hex-encoded data to be padded

cipherAlg CipherAlgorithm

Block cipher being used

pad Padding

Padding method to use

Return Value

String
Padded data in hex-encoded string

See Also

Cipher Class
CryptoSysAPI Namespace

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

Remove padding from an encryption block.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Unpad(Byte[], CipherAlgorithm, Padding) Remove padding from an encryption block.
Unpad(String, CipherAlgorithm, Padding) Remove padding from a hex-encoded encryption block.

Syntax

public static byte[] Unpad(
    byte[] input,
    CipherAlgorithm cipherAlg,
    Padding pad
)

Parameters

input Byte[]

padded data

cipherAlg CipherAlgorithm

Block cipher being used

pad Padding

Padding method to use

Return Value

Byte[]
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.

See Also

Cipher Class
CryptoSysAPI Namespace

Cipher.Unpad(String, CipherAlgorithm, Padding) Method

Remove padding from a hex-encoded encryption block.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Unpad(Byte[], CipherAlgorithm, Padding) Remove padding from an encryption block.
Unpad(String, CipherAlgorithm, Padding) Remove padding from a hex-encoded encryption block.

Syntax

public static string Unpad(
    string inputHex,
    CipherAlgorithm cipherAlg,
    Padding pad
)

Parameters

inputHex String

hex-encoded padded data

cipherAlg CipherAlgorithm

Block cipher being used

pad Padding

Padding method to use

Return Value

String
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.

See Also

Cipher Class
CryptoSysAPI Namespace

Cipher.Update(Byte[]) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction.
Update(String) Transform hex string data with previously initialized key, mode and direction

Syntax

public byte[] Update(
    byte[] data
)

Parameters

data Byte[]

Input data in byte array.

Return Value

Byte[]
Transformed data in byte array.

See Also

Cipher Class
CryptoSysAPI Namespace

Cipher.Update(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction.
Update(String) Transform hex string data with previously initialized key, mode and direction

Syntax

public string Update(
    string dataHex
)

Parameters

dataHex String

Hex-encoded input data

Return Value

String
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).

See Also

Cipher Class
CryptoSysAPI Namespace

CipherStream Class

Stream cipher algorithms

Inheritance Hierarchy

System.Object
CryptoSysAPI.CipherStream

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class CipherStream : IDisposable

The CipherStream type exposes the following members.

Properties

Name Description
ErrCode Last error code (for Init and Update methods only)

Methods

Name Description
Bytes Enciphers data in array of bytes using specified stream cipher.
Dispose Dispose of this object and clear any key schedules
File Enciphers data in a file using specified stream cipher.
Hex Enciphers data in a hex-encoded string using specified stream cipher.
Init Initializes the context ready for repeated operations of CipherStream.Update
Instance Create the one and only instance
Update Encrypts input using current context

See Also

CryptoSysAPI Namespace

CipherStream.ErrCode Property

Last error code (for Init and Update methods only)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int ErrCode { get; }

Property Value

Int32

See Also

CipherStream Class
CryptoSysAPI Namespace

CipherStream.Bytes Method

Enciphers data in array of bytes using specified stream cipher.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] Bytes(
    byte[] input,
    byte[] key,
    byte[] iv,
    int counter,
    CipherStream.Algorithm streamAlg
)

Parameters

input Byte[]

Input data to be encrypted

key Byte[]

Key

iv Byte[]

Initialization Vector (IV, nonce) or null for Arcfour

counter Int32

Counter value for ChaCha20 only, otherwise ignored. Use 0 for default.

streamAlg CipherStream.Algorithm

Stream cipher algorithm

Return Value

Byte[]
Ciphertext in byte array, or empty array on error

Remarks

Arcfour: any length key; specify null for IV.Salsa20: key must be exactly 16 or 32 bytes and IV exactly 8 bytes long.ChaCha20: key must be exactly 16 or 32 bytes and IV exactly 8, 12, or 16 bytes long. Counter is ignored if IV is 16 bytes.

See Also

CipherStream Class
CryptoSysAPI Namespace

CipherStream.Dispose Method

Dispose of this object and clear any key schedules

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public void Dispose()

Implements

IDisposable.Dispose()

See Also

CipherStream Class
CryptoSysAPI Namespace

CipherStream.File Method

Enciphers data in a file using specified stream cipher.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static int File(
    string fileOut,
    string fileIn,
    byte[] key,
    byte[] iv,
    int counter,
    CipherStream.Algorithm streamAlg
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key

iv Byte[]

Initialization Vector (IV, nonce) or null for Arcfour

counter Int32

Counter value for ChaCha20 only, otherwise ignored. Use 0 for default.

streamAlg CipherStream.Algorithm

Stream cipher algorithm

Return Value

Int32
0 if successful or nonzero error code

Remarks

fileOut and fileIn must not be the same Arcfour: any length key; specify null for IV.Salsa20: key must be exactly 16 or 32 bytes and IV exactly 8 bytes long.ChaCha20: key must be exactly 16 or 32 bytes and IV exactly 8, 12, or 16 bytes long. Counter is ignored if IV is 16 bytes.

See Also

CipherStream Class
CryptoSysAPI Namespace

CipherStream.Hex Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string Hex(
    string inputHex,
    string keyHex,
    string ivHex,
    int counter,
    CipherStream.Algorithm streamAlg
)

Parameters

inputHex String

Hex-encoded input data

keyHex String

Hex-encoded key

ivHex String

Hex-encoded Initialization Vector (IV, nonce) or "" for Arcfour

counter Int32

Counter value for ChaCha20 only, otherwise ignored. Use 0 for default.

streamAlg CipherStream.Algorithm

Stream cipher algorithm

Return Value

String
Ciphertext in hex-encoded string or empty string on error

Remarks

Arcfour: any length key; specify null for IV.Salsa20: key must be exactly 16 or 32 bytes and IV exactly 8 bytes long.ChaCha20: key must be exactly 16 or 32 bytes and IV exactly 8, 12, or 16 bytes long. Counter is ignored if IV is 16 bytes.

See Also

CipherStream Class
CryptoSysAPI Namespace

CipherStream.Init Method

Initializes the context ready for repeated operations of CipherStream.Update

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int Init(
    byte[] key,
    byte[] iv,
    int counter,
    CipherStream.Algorithm streamAlg
)

Parameters

key Byte[]

Key

iv Byte[]

Initialization Vector (IV, nonce) or null for Arcfour

counter Int32

Counter value for ChaCha20 only, otherwise ignored. Use 0 for default.

streamAlg CipherStream.Algorithm

Stream cipher algorithm

Return Value

Int32
0 if successful or nonzero error code

Remarks

Arcfour: any length key; specify null for IV.Salsa20: key must be exactly 16 or 32 bytes and IV exactly 8 bytes long.ChaCha20: key must be exactly 16 or 32 bytes and IV exactly 8, 12, or 16 bytes long. Counter is ignored if IV is 16 bytes.

See Also

CipherStream Class
CryptoSysAPI Namespace

CipherStream.Update Method

Encrypts input using current context

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public byte[] Update(
    byte[] input
)

Parameters

input Byte[]

Input data to be encrypted

Return Value

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

Remarks

Check CipherStream.ErrCode for error details

See Also

CipherStream Class
CryptoSysAPI Namespace

CipherStream.Instance Method

Create the one and only instance

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static CipherStream Instance()

Return Value

CipherStream
Single instance to class

Remarks

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

See Also

CipherStream Class
CryptoSysAPI Namespace

Cnv Class

Character conversion routines

Inheritance Hierarchy

System.Object
CryptoSysAPI.Cnv

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Cnv

The Cnv type exposes the following members.

Methods

Name Description
Base64Filter Filters non-base64 characters from a string
Base64FromHex Converts hexadecimal-encoded data into base64-encoded data
FromBase64 Converts a base64-encoded string to an equivalent array of 8-bit unsigned integers.
FromHex Converts a hexadecimal-encoded string to an equivalent array of 8-bit unsigned integers.
HexFilter Filters non-hexadecimal characters from a string
HexFromBase64 Converts base64-encoded data into hexadecimal-encoded data
ShortPathName Retrieve the Windows short path form of the specified path.
StringFromBase64 Converts a base64-encoded string into a text string
StringFromHex Converts a hexadecimal-encoded string into a text string
ToBase64(Byte[]) Converts 8-bit binary data to equivalent base64-encoded string format
ToBase64(String) Converts a string of ANSI characters to equivalent base64-encoded string format
ToHex(Byte[]) Converts 8-bit binary data to equivalent hexadecimal string format
ToHex(String) Converts a string of ANSI characters to equivalent hexadecimal string format

See Also

CryptoSysAPI Namespace

Cnv.Base64Filter Method

Filters non-base64 characters from a string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string Base64Filter(
    string s
)

Parameters

s String

String to be filtered

Return Value

String
Filtered string

Remarks

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

See Also

Cnv Class
CryptoSysAPI Namespace

Cnv.Base64FromHex Method

Converts hexadecimal-encoded data into base64-encoded data

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string Base64FromHex(
    string s
)

Parameters

s String

Hex-encoded data

Return Value

String
Base64-encoded data

See Also

Cnv Class
CryptoSysAPI Namespace

Cnv.FromBase64 Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] FromBase64(
    string s
)

Parameters

s String

Base64-encoded data

Return Value

Byte[]
Data as array of bytes

See Also

Cnv Class
CryptoSysAPI Namespace

Cnv.FromHex Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] FromHex(
    string s
)

Parameters

s String

Hex-encoded data

Return Value

Byte[]
Data as array of bytes

See Also

Cnv Class
CryptoSysAPI Namespace

Cnv.HexFilter Method

Filters non-hexadecimal characters from a string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string HexFilter(
    string s
)

Parameters

s String

String to be filtered

Return Value

String
Filtered string

Remarks

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

See Also

Cnv Class
CryptoSysAPI Namespace

Cnv.HexFromBase64 Method

Converts base64-encoded data into hexadecimal-encoded data

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string HexFromBase64(
    string s
)

Parameters

s String

Base64-encoded data

Return Value

String
Hex-encoded data

See Also

Cnv Class
CryptoSysAPI Namespace

Cnv.ShortPathName Method

Retrieve the Windows short path form of the specified path.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string ShortPathName(
    string pathName
)

Parameters

pathName String

File path name.

Return Value

String
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.

See Also

Cnv Class
CryptoSysAPI Namespace

Cnv.StringFromBase64 Method

Converts a base64-encoded string into a text string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string StringFromBase64(
    string s
)

Parameters

s String

Base64-encoded data

Return Value

String
String value

Remarks

Uses the ‘Default’ encoding for the system’s current ANSI code page

See Also

Cnv Class
CryptoSysAPI Namespace

Cnv.StringFromHex Method

Converts a hexadecimal-encoded string into a text string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string StringFromHex(
    string s
)

Parameters

s String

Hex-encoded data

Return Value

String
String value

Remarks

Uses the ‘Default’ encoding for the system’s current ANSI code page

See Also

Cnv Class
CryptoSysAPI Namespace

Cnv.ToBase64(Byte[]) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
ToBase64(Byte[]) Converts 8-bit binary data to equivalent base64-encoded string format
ToBase64(String) Converts a string of ANSI characters to equivalent base64-encoded string format

Syntax

public static string ToBase64(
    byte[] binaryData
)

Parameters

binaryData Byte[]

binary data

Return Value

String
Base64-encoded string

See Also

Cnv Class
CryptoSysAPI Namespace

Cnv.ToBase64(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
ToBase64(Byte[]) Converts 8-bit binary data to equivalent base64-encoded string format
ToBase64(String) Converts a string of ANSI characters to equivalent base64-encoded string format

Syntax

public static string ToBase64(
    string s
)

Parameters

s String

String of data to be encoded

Return Value

String
Base64-encoded data

Remarks

Uses the ‘Default’ encoding for the system’s current ANSI code page

See Also

Cnv Class
CryptoSysAPI Namespace

Cnv.ToHex(Byte[]) Method

Converts 8-bit binary data to equivalent hexadecimal string format

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
ToHex(Byte[]) Converts 8-bit binary data to equivalent hexadecimal string format
ToHex(String) Converts a string of ANSI characters to equivalent hexadecimal string format

Syntax

public static string ToHex(
    byte[] binaryData
)

Parameters

binaryData Byte[]

binary data

Return Value

String
Hex-encoded string

See Also

Cnv Class
CryptoSysAPI Namespace

Cnv.ToHex(String) Method

Converts a string of ANSI characters to equivalent hexadecimal string format

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
ToHex(Byte[]) Converts 8-bit binary data to equivalent hexadecimal string format
ToHex(String) Converts a string of ANSI characters to equivalent hexadecimal string format

Syntax

public static string ToHex(
    string s
)

Parameters

s String

String of data to be encoded

Return Value

String
Hex-encoded data

Remarks

Uses the ‘Default’ encoding for the system’s current ANSI code page

See Also

Cnv Class
CryptoSysAPI Namespace

Compr Class

Compression utilities

Inheritance Hierarchy

System.Object
CryptoSysAPI.Compr

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Compr

The Compr type exposes the following members.

Methods

Name Description
Compress Compress data using compression algorithm.
Uncompress Uncompress data using compression algorithm.

See Also

CryptoSysAPI Namespace

Compr.Compress Method

Compress data using compression algorithm.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] Compress(
    byte[] data,
    ComprAlgorithm comprAlg = ComprAlgorithm.Zlib
)

Parameters

data Byte[]

Data to be compressed.

comprAlg ComprAlgorithm (Optional)

Compression algorithm.

Return Value

Byte[]
Compressed data, or an empty array on error.

See Also

Compr Class
CryptoSysAPI Namespace

Compr.Uncompress Method

Uncompress data using compression algorithm.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] Uncompress(
    byte[] data,
    ComprAlgorithm comprAlg = ComprAlgorithm.Zlib
)

Parameters

data Byte[]

Compressed data to be uncompressed.

comprAlg ComprAlgorithm (Optional)

Compression algorithm.

Return Value

Byte[]
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.

See Also

Compr Class
CryptoSysAPI Namespace

Crc Class

CRC-32 computations

Inheritance Hierarchy

System.Object
CryptoSysAPI.Crc

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Crc

The Crc type exposes the following members.

Methods

Name Description
Data(Byte[]) Computes CRC-32 checksum for data
Data(String) Computes CRC-32 checksum for a string
File Computes CRC-32 checksum for a file

See Also

CryptoSysAPI Namespace

Crc.Data(Byte[]) Method

Computes CRC-32 checksum for data

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Data(Byte[]) Computes CRC-32 checksum for data
Data(String) Computes CRC-32 checksum for a string

Syntax

public static int Data(
    byte[] data
)

Parameters

data Byte[]

input data

Return Value

Int32
Value of CRC-32 checksum

See Also

Crc Class
CryptoSysAPI Namespace

Crc.Data(String) Method

Computes CRC-32 checksum for a string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Data(Byte[]) Computes CRC-32 checksum for data
Data(String) Computes CRC-32 checksum for a string

Syntax

public static int Data(
    string Str
)

Parameters

Str String

input data

Return Value

Int32
Value of CRC-32 checksum

See Also

Crc Class
CryptoSysAPI Namespace

Crc.File Method

Computes CRC-32 checksum for a file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static int File(
    string fileName
)

Parameters

fileName String

Name of input file

Return Value

Int32
Value of CRC-32 checksum

Remarks

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

See Also

Crc Class
CryptoSysAPI Namespace

Des Class

Data Encryption Standard (DES) Cipher (legacy applications only)

Inheritance Hierarchy

System.Object
CryptoSysAPI.Des

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Des : IDisposable

The Des type exposes the following members.

Properties

Name Description
ErrCode Last error code (for Init and Update methods only)

Methods

Name Description
CheckKey(Byte[]) Verifies that no part of the key is a weak or semi-weak DES key.
CheckKey(String) Verifies that no part of the key is a weak or semi-weak DES key.
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string
Dispose Dispose of this object and clear any key schedules
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting
Instance Create the one and only instance
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block
Update(Byte[]) Transforms byte input data with previously initialized key, mode and direction
Update(String) Transforms hex string data with previously initialized key, mode and direction

Fields

Name Description
BlockSize Block size in bytes

See Also

CryptoSysAPI Namespace

Des.ErrCode Property

Last error code (for Init and Update methods only)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int ErrCode { get; }

Property Value

Int32

See Also

Des Class
CryptoSysAPI Namespace

Des.CheckKey(Byte[]) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
CheckKey(Byte[]) Verifies that no part of the key is a weak or semi-weak DES key.
CheckKey(String) Verifies that no part of the key is a weak or semi-weak DES key.

Syntax

public static int CheckKey(
    byte[] key
)

Parameters

key Byte[]

Key to check

Return Value

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

See Also

Des Class
CryptoSysAPI Namespace

Des.CheckKey(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
CheckKey(Byte[]) Verifies that no part of the key is a weak or semi-weak DES key.
CheckKey(String) Verifies that no part of the key is a weak or semi-weak DES key.

Syntax

public static int CheckKey(
    string keyHex
)

Parameters

keyHex String

Hex-encoded key to check

Return Value

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

See Also

Des Class
CryptoSysAPI Namespace

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

Decrypt data in byte array

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static byte[] Decrypt(
    byte[] input,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

input Byte[]

Input data

key Byte[]

Key of exactly 8 bytes (64 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Byte[]
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)

See Also

Des Class
CryptoSysAPI Namespace

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

Decrypt hex-encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static string Decrypt(
    string inputHex,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

inputHex String

Hex-encoded input data

keyHex String

Hex-encoded key representing exactly 8 bytes (64 bits)

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV representing exactly 8 bytes or "" for ECB mode

Return Value

String
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)

See Also

Des Class
CryptoSysAPI Namespace

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

Decrypt encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static string Decrypt(
    string inputStr,
    string keyStr,
    Mode mode,
    string ivStr,
    EncodingBase encodingBase
)

Parameters

inputStr String

Encoded input data

keyStr String

Encoded key representing exactly 8 bytes (64 bits)

mode Mode

Cipher Mode

ivStr String

Encoded IV representing exactly 8 bytes or "" for ECB mode

encodingBase EncodingBase

Type of encoding used

Return Value

String
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)

See Also

Des Class
CryptoSysAPI Namespace

Des.Dispose Method

Dispose of this object and clear any key schedules

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public void Dispose()

Implements

IDisposable.Dispose()

See Also

Des Class
CryptoSysAPI Namespace

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

Encrypt data in byte array

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static byte[] Encrypt(
    byte[] input,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

input Byte[]

Input data

key Byte[]

Key of exactly 8 bytes (64 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Byte[]
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)

See Also

Des Class
CryptoSysAPI Namespace

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

Encrypt hex-encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static string Encrypt(
    string inputHex,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

inputHex String

Hex-encoded input data

keyHex String

Hex-encoded key representing exactly 8 bytes (64 bits)

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV representing exactly 8 bytes or "" for ECB mode

Return Value

String
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)

See Also

Des Class
CryptoSysAPI Namespace

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

Encrypt encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static string Encrypt(
    string inputStr,
    string keyStr,
    Mode mode,
    string ivStr,
    EncodingBase encodingBase
)

Parameters

inputStr String

Encoded input data

keyStr String

Encoded key representing exactly 8 bytes (64 bits)

mode Mode

Cipher Mode

ivStr String

Encoded IV representing exactly 8 bytes or "" for ECB mode

encodingBase EncodingBase

Type of encoding used

Return Value

String
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)

See Also

Des Class
CryptoSysAPI Namespace

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

Decrypt a file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 8 bytes (64 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Des Class
CryptoSysAPI Namespace

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

Decrypt a file passing key and IV as hex strings

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

keyHex String

Hex-encoded key of exact length

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV or "" for ECB mode

Return Value

Int32
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.

See Also

Des Class
CryptoSysAPI Namespace

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

Decrypt a file with advanced options

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv,
    CipherFileOption advOptions
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 8 bytes (64 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes. Use null/Nothing for ECB mode or when using CipherFileOption.PrefixIV option

advOptions CipherFileOption

Advanced options. See CipherFileOption.

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Des Class
CryptoSysAPI Namespace

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

Encrypt a file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 8 bytes (64 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Des Class
CryptoSysAPI Namespace

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

Encrypt a file passing key and IV as hex strings

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

keyHex String

Hex-encoded key of exact length

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV or "" for ECB mode

Return Value

Int32
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.

See Also

Des Class
CryptoSysAPI Namespace

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

Encrypt a file with advanced options

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv,
    CipherFileOption advOptions
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 8 bytes (64 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

advOptions CipherFileOption

Advanced options. See CipherFileOption.

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Des Class
CryptoSysAPI Namespace

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

Initializes with key, mode and IV ready to start decrypting

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

public int InitDecrypt(
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

key Byte[]

Key of exactly 8 bytes (64 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

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

See Also

Des Class
CryptoSysAPI Namespace

Des.InitDecrypt(String, Mode, String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

public int InitDecrypt(
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

keyHex String

Key in hex-encoded format

mode Mode

Cipher mode

ivHex String

IV in hex-encoded format

Return Value

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

See Also

Des Class
CryptoSysAPI Namespace

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

Initializes with key, mode and IV ready to start encrypting

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

public int InitEncrypt(
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

key Byte[]

Key of exactly 8 bytes (64 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

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

See Also

Des Class
CryptoSysAPI Namespace

Des.InitEncrypt(String, Mode, String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

public int InitEncrypt(
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

keyHex String

Key in hex-encoded format

mode Mode

Cipher mode

ivHex String

IV in hex-encoded format

Return Value

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

See Also

Des Class
CryptoSysAPI Namespace

Des.Instance Method

Create the one and only instance

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static Des Instance()

Return Value

Des
Single instance to class

See Also

Des Class
CryptoSysAPI Namespace

Des.Pad(Byte[]) Method

Pads byte array to correct length for ECB and CBC encryption

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

public static byte[] Pad(
    byte[] data
)

Parameters

data Byte[]

data to be padded

Return Value

Byte[]
padded data in byte array

Remarks

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

See Also

Des Class
CryptoSysAPI Namespace

Des.Pad(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

public static string Pad(
    string dataHex
)

Parameters

dataHex String

hex-encoded data to be padded

Return Value

String
padded data in hex-encoded string

Remarks

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

See Also

Des Class
CryptoSysAPI Namespace

Des.Unpad(Byte[]) Method

Removes the padding from an encryption block

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block

Syntax

public static byte[] Unpad(
    byte[] data
)

Parameters

data Byte[]

padded data

Return Value

Byte[]
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.

See Also

Des Class
CryptoSysAPI Namespace

Des.Unpad(String) Method

Removes the padding from a hex-encoded encryption block

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block

Syntax

public static string Unpad(
    string dataHex
)

Parameters

dataHex String

hex-encoded padded data

Return Value

String
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.

See Also

Des Class
CryptoSysAPI Namespace

Des.Update(Byte[]) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Update(Byte[]) Transforms byte input data with previously initialized key, mode and direction
Update(String) Transforms hex string data with previously initialized key, mode and direction

Syntax

public byte[] Update(
    byte[] data
)

Parameters

data Byte[]

input data in byte array

Return Value

Byte[]
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)

See Also

Des Class
CryptoSysAPI Namespace

Des.Update(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Update(Byte[]) Transforms byte input data with previously initialized key, mode and direction
Update(String) Transforms hex string data with previously initialized key, mode and direction

Syntax

public string Update(
    string data
)

Parameters

data String

hex-encoded input data

Return Value

String
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)

See Also

Des Class
CryptoSysAPI Namespace

Des.BlockSize Field

Block size in bytes

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public const int BlockSize = 8

Field Value

Int32

See Also

Des Class
CryptoSysAPI Namespace

Gcm Class

Provides authenticated encryption using the Galois/Counter Mode (GCM) of operation with the AES algorithm (AES-GCM).

Inheritance Hierarchy

System.Object
CryptoSysAPI.Gcm

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Gcm : IDisposable

The Gcm type exposes the following members.

Properties

Name Description
ErrCode Last error code (object-related only)

Methods

Name Description
Decrypt Decrypt input using AES-GCM in one-off operation
Dispose Dispose of this object and clear any key schedules
Encrypt Encrypt input using AES-GCM in one-off operation
Gmac Compute GMAC using AES-GCM in one-off operation
InitKey Initializes the context with the key ready for repeated operations of Gcm.NextEncrypt, Gcm.NextDecrypt, or Gcm.NextGmac.
Instance Create the one and only instance
NextDecrypt Carries out the GCM decryption operation using the key set up by an earlier call to Gcm.InitKey.
NextEncrypt Carries out the GCM encryption operation using the key set up by an earlier call to Gcm.InitKey.
NextGmac Carries out the GMAC operation using the key set up by an earlier call to Gcm.InitKey.

Fields

Name Description
TagMaxSize Maximum size of tag in bytes

See Also

CryptoSysAPI Namespace

Gcm.ErrCode Property

Last error code (object-related only)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int ErrCode { get; }

Property Value

Int32

See Also

Gcm Class
CryptoSysAPI Namespace

Gcm.Decrypt Method

Decrypt input using AES-GCM in one-off operation

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] Decrypt(
    byte[] input,
    byte[] key,
    byte[] iv,
    byte[] aad,
    byte[] tag
)

Parameters

input Byte[]

Cipher text input data

key Byte[]

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

iv Byte[]

Initialization vector.

aad Byte[]

Additional authentication data (optional). Pass null/Nothing to ignore.

tag Byte[]

Tag value (required)

Return Value

Byte[]
Decrypted plaintext in byte array, or empty array on error

Remarks

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

See Also

Gcm Class
CryptoSysAPI Namespace

Gcm.Dispose Method

Dispose of this object and clear any key schedules

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public void Dispose()

Implements

IDisposable.Dispose()

See Also

Gcm Class
CryptoSysAPI Namespace

Gcm.Encrypt Method

Encrypt input using AES-GCM in one-off operation

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] Encrypt(
    out byte[] tag,
    byte[] input,
    byte[] key,
    byte[] iv,
    byte[] aad
)

Parameters

tag Byte[]

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 Byte[]

Plain text input data

key Byte[]

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

iv Byte[]

Initialization vector: can be any length but 12 bytes is recommended.

aad Byte[]

Additional authentication data (optional). Pass null/Nothing to ignore.

Return Value

Byte[]
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.

See Also

Gcm Class
CryptoSysAPI Namespace

Gcm.Gmac Method

Compute GMAC using AES-GCM in one-off operation

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] Gmac(
    byte[] key,
    byte[] iv,
    byte[] msg
)

Parameters

key Byte[]

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

iv Byte[]

Initialization vector

msg Byte[]

Message data

Return Value

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

Remarks

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

See Also

Gcm Class
CryptoSysAPI Namespace

Gcm.InitKey Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int InitKey(
    byte[] key
)

Parameters

key Byte[]

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

Return Value

Int32
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

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

See Also

Gcm Class
CryptoSysAPI Namespace

Gcm.NextEncrypt Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public byte[] NextEncrypt(
    out byte[] tag,
    byte[] input,
    byte[] iv,
    byte[] aad
)

Parameters

tag Byte[]

Tag value, always returned exactly 16 bytes long. You may truncate as desired.

input Byte[]

Plain text input data

iv Byte[]

Initialization vector: can be any length but 12 bytes is recommended.

aad Byte[]

Additional authentication data (optional). Pass null/Nothing to ignore.

Return Value

Byte[]
Encrypted ciphertext in byte array, or empty array on error

See Also

Gcm Class
CryptoSysAPI Namespace

Gcm.NextDecrypt Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public byte[] NextDecrypt(
    byte[] input,
    byte[] iv,
    byte[] aad,
    byte[] tag
)

Parameters

input Byte[]

Cipher text input data

iv Byte[]

Initialization vector.

aad Byte[]

Additional authentication data (optional). Pass null/Nothing to ignore.

tag Byte[]

Tag value (required)

Return Value

Byte[]
Decrypted plaintext in byte array, or empty array on error

See Also

Gcm Class
CryptoSysAPI Namespace

Gcm.NextGmac Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public byte[] NextGmac(
    byte[] iv,
    byte[] msg
)

Parameters

iv Byte[]

Initialization vector.

msg Byte[]

Message data.

Return Value

Byte[]
GMAC value in byte array, or empty array on error

See Also

Gcm Class
CryptoSysAPI Namespace

Gcm.Instance Method

Create the one and only instance

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static Gcm Instance()

Return Value

Gcm
Single instance to class

See Also

Gcm Class
CryptoSysAPI Namespace

Gcm.TagMaxSize Field

Maximum size of tag in bytes

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public const int TagMaxSize = 16

Field Value

Int32

See Also

Gcm Class
CryptoSysAPI Namespace

General Class

General functions

Inheritance Hierarchy

System.Object
CryptoSysAPI.General

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class General

The General type exposes the following members.

Methods

Name Description
CompileTime Gets date and time the CryptoSys DLL module was last compiled
ErrorCode Returns the error code of the error that occurred when calling the last function
ErrorLookup Looks up error code
FormatErrorMessage Return an error message string for the last error.
IsWin64 Returns flag indicating the platform of the core DLL.
LicenceType Gets licence type.
ModuleInfo Get additional information about the core DLL module.
ModuleName Gets full path name of core CryptoSys DLL module
NetVersion Return the version of this .NET module.
Platform Return the platform the core DLL was compiled for.
PowerUpTests Performs FIPS-140-2 start-up tests
Version Returns version number of core CryptoSys DLL.

See Also

CryptoSysAPI Namespace

General.CompileTime Method

Gets date and time the CryptoSys DLL module was last compiled

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string CompileTime()

Return Value

String
Date and time string

See Also

General Class
CryptoSysAPI Namespace

General.FormatErrorMessage Method

Return an error message string for the last error.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string FormatErrorMessage(
    int errCode = 0
)

Parameters

errCode Int32 (Optional)

Error code returned by last call (optional)

Return Value

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

See Also

General Class
CryptoSysAPI Namespace

General.IsWin64 Method

Returns flag indicating the platform of the core DLL.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static int IsWin64()

Return Value

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

See Also

General Class
CryptoSysAPI Namespace

General.LicenceType Method

Gets licence type.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static char LicenceType()

Return Value

Char
D=Developer T=Trial

See Also

General Class
CryptoSysAPI Namespace

General.ModuleInfo Method

Get additional information about the core DLL module.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string ModuleInfo()

Return Value

String
STring containing additional information, e.g. "Licensed Developer Edition"

See Also

General Class
CryptoSysAPI Namespace

General.ModuleName Method

Gets full path name of core CryptoSys DLL module

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string ModuleName()

Return Value

String
File name

See Also

General Class
CryptoSysAPI Namespace

General.NetVersion Method

Return the version of this .NET module.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string NetVersion()

Return Value

String
Version string, e.g. "03.05.00"

See Also

General Class
CryptoSysAPI Namespace

General.Platform Method

Return the platform the core DLL was compiled for.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string Platform()

Return Value

String
"Win32" or "X64"

See Also

General Class
CryptoSysAPI Namespace

General.PowerUpTests Method

Performs FIPS-140-2 start-up tests

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static int PowerUpTests()

Return Value

Int32
Zero on success

See Also

General Class
CryptoSysAPI Namespace

General.Version Method

Returns version number of core CryptoSys DLL.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static int Version()

Return Value

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

Remarks

For example, version 5.2.1 returns 50201

See Also

General Class
CryptoSysAPI Namespace

Hash Class

Message Digest Hash Functions

Inheritance Hierarchy

System.Object
CryptoSysAPI.Hash

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Hash

The Hash type exposes the following members.

Properties

Name Description
ErrCode Last error code (for Init, AddData and Final object methods only)

Methods

Name Description
AddData(Byte[]) Adds a chunk of data in a byte array to be digested by the Hash object.
AddData(String) Adds a chunk of data in a string to be digested by the Hash object.
BytesFromBytes Computes hash value in byte format of byte input
BytesFromFile Computes hash value in byte format of a binary file
Dispose Dispose of this object and clear any stored data.
Final Computes final message digest for the Hash object.
HexFromBits Computes hash value in hex format from bit-oriented input
HexFromBytes Computes hash value in hex format of byte input
HexFromFile Computes hash value in hex format of a binary file
HexFromHex Computes hash value in hex format of hex-encoded input
HexFromString Computes hash value in hex format of string input
HexFromTextFile Computes hash value in hex format of a text file, treating CR-LF pairs as a single LF
Init Initialises the Hash object ready for repeated incremental operations.
Instance Create the one and only instance
LengthInBytes Returns the number of bytes in the message digest for the given hash algorithm.
Reset Resets the context of the Hash object.

See Also

CryptoSysAPI Namespace

Hash.ErrCode Property

Last error code (for Init, AddData and Final object methods only)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int ErrCode { get; }

Property Value

Int32

See Also

Hash Class
CryptoSysAPI Namespace

Hash.AddData(Byte[]) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
AddData(Byte[]) Adds a chunk of data in a byte array to be digested by the Hash object.
AddData(String) Adds a chunk of data in a string to be digested by the Hash object.

Syntax

public int AddData(
    byte[] b
)

Parameters

b Byte[]

Data to add

Return Value

Int32
0 on success or nonzero error code

See Also

Hash Class
CryptoSysAPI Namespace

Hash.AddData(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
AddData(Byte[]) Adds a chunk of data in a byte array to be digested by the Hash object.
AddData(String) Adds a chunk of data in a string to be digested by the Hash object.

Syntax

public int AddData(
    string s
)

Parameters

s String

Data to add

Return Value

Int32
0 on success or nonzero error code

See Also

Hash Class
CryptoSysAPI Namespace

Hash.BytesFromBytes Method

Computes hash value in byte format of byte input

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] BytesFromBytes(
    byte[] message,
    HashAlgorithm hashAlg
)

Parameters

message Byte[]

Message data in byte format

hashAlg HashAlgorithm

Hash algorithm to be used

Return Value

Byte[]
Message digest in byte format

See Also

Hash Class
CryptoSysAPI Namespace

Hash.BytesFromFile Method

Computes hash value in byte format of a binary file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] BytesFromFile(
    string fileName,
    HashAlgorithm hashAlg
)

Parameters

fileName String

Name of file containing message data

hashAlg HashAlgorithm

Hash algorithm to be used (ASCON-HASH not supported in file mode)

Return Value

Byte[]
Message digest in byte format

See Also

Hash Class
CryptoSysAPI Namespace

Hash.Dispose Method

Dispose of this object and clear any stored data.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public void Dispose()

See Also

Hash Class
CryptoSysAPI Namespace

Hash.Final Method

Computes final message digest for the Hash object.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public byte[] Final()

Return Value

Byte[]
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.

See Also

Hash Class
CryptoSysAPI Namespace

Hash.HexFromBits Method

Computes hash value in hex format from bit-oriented input

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string HexFromBits(
    byte[] data,
    int dataBitLen,
    HashAlgorithm hashAlg
)

Parameters

data Byte[]

Bit-oriented message data in byte array

dataBitLen Int32

Number of bits in data to digest

hashAlg HashAlgorithm

Hash algorithm to be used (SHA-1, SHA-2, SHA-3 only)

Return Value

String
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

See Also

Hash Class
CryptoSysAPI Namespace

Hash.HexFromBytes Method

Computes hash value in hex format of byte input

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string HexFromBytes(
    byte[] message,
    HashAlgorithm hashAlg
)

Parameters

message Byte[]

Message data in byte format

hashAlg HashAlgorithm

Hash algorithm to be used

Return Value

String
Message digest in hex-encoded format

See Also

Hash Class
CryptoSysAPI Namespace

Hash.HexFromFile Method

Computes hash value in hex format of a binary file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string HexFromFile(
    string fileName,
    HashAlgorithm hashAlg
)

Parameters

fileName String

Name of file containing message data

hashAlg HashAlgorithm

Hash algorithm to be used (ASCON-HASH not supported in file mode)

Return Value

String
Message digest in hex-encoded format

See Also

Hash Class
CryptoSysAPI Namespace

Hash.HexFromHex Method

Computes hash value in hex format of hex-encoded input

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string HexFromHex(
    string messageHex,
    HashAlgorithm hashAlg
)

Parameters

messageHex String

Message data in hex-encoded format

hashAlg HashAlgorithm

Hash algorithm to be used

Return Value

String
Message digest in hex-encoded format

See Also

Hash Class
CryptoSysAPI Namespace

Hash.HexFromString Method

Computes hash value in hex format of string input

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string HexFromString(
    string message,
    HashAlgorithm hashAlg
)

Parameters

message String

Message data string

hashAlg HashAlgorithm

Hash algorithm to be used

Return Value

String
Message digest in hex-encoded format

See Also

Hash Class
CryptoSysAPI Namespace

Hash.HexFromTextFile Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string HexFromTextFile(
    string fileName,
    HashAlgorithm hashAlg
)

Parameters

fileName String

Name of file containing message data

hashAlg HashAlgorithm

Hash algorithm to be used (ASCON-HASH not supported in file mode)

Return Value

String
Message digest in hex format

Remarks

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

See Also

Hash Class
CryptoSysAPI Namespace

Hash.Init Method

Initialises the Hash object ready for repeated incremental operations.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public bool Init(
    HashAlgorithm hashAlg
)

Parameters

hashAlg HashAlgorithm

Hash algorithm to be used (SHA-1, SHA-2, SHA-3 only)

Return Value

Boolean
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.

See Also

Hash Class
CryptoSysAPI Namespace

Hash.Instance Method

Create the one and only instance

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static Hash Instance()

Return Value

Hash
Single instance to class

See Also

Hash Class
CryptoSysAPI Namespace

Hash.LengthInBytes Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static int LengthInBytes(
    HashAlgorithm hashAlg
)

Parameters

hashAlg HashAlgorithm

Hash algorithm

Return Value

Int32
The length in bytes of the message digest output.

See Also

Hash Class
CryptoSysAPI Namespace

Hash.Reset Method

Resets the context of the Hash object.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int Reset()

Return Value

Int32
0 on success or a nonzero error code.

See Also

Hash Class
CryptoSysAPI Namespace

Mac Class

Message authentication code (MAC) functions

Inheritance Hierarchy

System.Object
CryptoSysAPI.Mac

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Mac

The Mac type exposes the following members.

Properties

Name Description
ErrCode Last error code (for Init, AddData and Final object methods only)

Methods

Name Description
AddData(Byte[]) Adds a chunk of data in a byte array to be authenticated by the Mac object.
AddData(String) Adds a chunk of data in a string to be authenticated by the Mac object.
BytesFromBytes Computes MAC value in byte format from byte input
Dispose Dispose of this object and clear any stored data.
Final Computes final MAC value for the Mac object.
HexFromBytes Computes MAC value in hex-encoded format from byte input
HexFromHex Computes MAC value in hex-encoded format from hex-encoded input
Init Initialises the Mac object ready for repeated incremental operations.
Instance Create the one and only instance
Reset Resets the context of the Mac object.

See Also

CryptoSysAPI Namespace

Mac.ErrCode Property

Last error code (for Init, AddData and Final object methods only)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int ErrCode { get; }

Property Value

Int32

See Also

Mac Class
CryptoSysAPI Namespace

Mac.AddData(Byte[]) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
AddData(Byte[]) Adds a chunk of data in a byte array to be authenticated by the Mac object.
AddData(String) Adds a chunk of data in a string to be authenticated by the Mac object.

Syntax

public int AddData(
    byte[] b
)

Parameters

b Byte[]

Data to add

Return Value

Int32
0 on success or nonzero error code

See Also

Mac Class
CryptoSysAPI Namespace

Mac.AddData(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
AddData(Byte[]) Adds a chunk of data in a byte array to be authenticated by the Mac object.
AddData(String) Adds a chunk of data in a string to be authenticated by the Mac object.

Syntax

public int AddData(
    string s
)

Parameters

s String

Data to add

Return Value

Int32
0 on success or nonzero error code

See Also

Mac Class
CryptoSysAPI Namespace

Mac.BytesFromBytes Method

Computes MAC value in byte format from byte input

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] BytesFromBytes(
    byte[] message,
    byte[] key,
    MacAlgorithm macAlg
)

Parameters

message Byte[]

Message to be signed in byte format

key Byte[]

Key in byte format

macAlg MacAlgorithm

MAC algorithm to be used

Return Value

Byte[]
MAC in byte format

See Also

Mac Class
CryptoSysAPI Namespace

Mac.Dispose Method

Dispose of this object and clear any stored data.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public void Dispose()

See Also

Mac Class
CryptoSysAPI Namespace

Mac.Final Method

Computes final MAC value for the Mac object.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public byte[] Final()

Return Value

Byte[]
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.

See Also

Mac Class
CryptoSysAPI Namespace

Mac.HexFromBytes Method

Computes MAC value in hex-encoded format from byte input

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string HexFromBytes(
    byte[] message,
    byte[] key,
    MacAlgorithm macAlg
)

Parameters

message Byte[]

Message to be signed in byte format

key Byte[]

Key in byte format

macAlg MacAlgorithm

MAC algorithm to be used

Return Value

String
MAC in hex-encoded format

See Also

Mac Class
CryptoSysAPI Namespace

Mac.HexFromHex Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string HexFromHex(
    string messageHex,
    string keyHex,
    MacAlgorithm macAlg
)

Parameters

messageHex String

Message to be signed in hex-encoded format

keyHex String

Key in hex-encoded format

macAlg MacAlgorithm

MAC algorithm to be used

Return Value

String
MAC in hex-encoded format

See Also

Mac Class
CryptoSysAPI Namespace

Mac.Init Method

Initialises the Mac object ready for repeated incremental operations.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public bool Init(
    byte[] key,
    MacAlgorithm macAlg
)

Parameters

key Byte[]

Key

macAlg MacAlgorithm

HMAC algorithm to be used.

Return Value

Boolean
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.

See Also

Mac Class
CryptoSysAPI Namespace

Mac.Instance Method

Create the one and only instance

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static Mac Instance()

Return Value

Mac
Single instance to class

See Also

Mac Class
CryptoSysAPI Namespace

Mac.Reset Method

Resets the context of the Mac object.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int Reset()

Return Value

Int32
0 on success or a nonzero error code.

See Also

Mac Class
CryptoSysAPI Namespace

Md5 Class

MD5 Hash Algorithm

Inheritance Hierarchy

System.Object
CryptoSysAPI.Md5

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Md5

The Md5 type exposes the following members.

Properties

Name Description
ErrCode Last error code (for Init, AddData and HexDigest methods only)

Methods

Name Description
AddData(Byte[]) Adds an array of 8-bit bytes to the digest
AddData(String) Adds a string of Ansi characters to the digest
BytesHash Creates message digest as array of bytes from message in byte array
Dispose Dispose of this object and clear any stored data
FileHexHash Creates hash digest of a binary file
FileTextHexHash Creates hash digest of a “text” file treating CR-LF pairs as a single newline char
HexDigest Computes final message digest in hex format
HexHash(Byte[]) Creates message digest in hex format from message in byte array
HexHash(String) Creates message digest in hex format from message in Ansi string
Hmac(Byte[], Byte[]) Computes the keyed hash digest of binary data using HMAC algorithm
Hmac(String, String) Computes the keyed hash digest using HMAC algorithm passing data as hex strings
Init Initializes the context
Instance Create the one and only instance
Reset Resets the context

See Also

CryptoSysAPI Namespace

Md5.ErrCode Property

Last error code (for Init, AddData and HexDigest methods only)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int ErrCode { get; }

Property Value

Int32

See Also

Md5 Class
CryptoSysAPI Namespace

Md5.AddData(Byte[]) Method

Adds an array of 8-bit bytes to the digest

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
AddData(Byte[]) Adds an array of 8-bit bytes to the digest
AddData(String) Adds a string of Ansi characters to the digest

Syntax

public int AddData(
    byte[] b
)

Parameters

b Byte[]

Data to add

Return Value

Int32
0 on success or nonzero error code

See Also

Md5 Class
CryptoSysAPI Namespace

Md5.AddData(String) Method

Adds a string of Ansi characters to the digest

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
AddData(Byte[]) Adds an array of 8-bit bytes to the digest
AddData(String) Adds a string of Ansi characters to the digest

Syntax

public int AddData(
    string s
)

Parameters

s String

String of Ansi characters

Return Value

Int32
0 on success or nonzero error code

See Also

Md5 Class
CryptoSysAPI Namespace

Md5.BytesHash Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] BytesHash(
    byte[] message
)

Parameters

message Byte[]

Message data to be digested

Return Value

Byte[]
Digest in array of bytes

See Also

Md5 Class
CryptoSysAPI Namespace

Md5.Dispose Method

Dispose of this object and clear any stored data

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public void Dispose()

See Also

Md5 Class
CryptoSysAPI Namespace

Md5.FileHexHash Method

Creates hash digest of a binary file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string FileHexHash(
    string fileName
)

Parameters

fileName String

Name of input file

Return Value

String
Message digest in hex format

See Also

Md5 Class
CryptoSysAPI Namespace

Md5.FileTextHexHash Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string FileTextHexHash(
    string fileName
)

Parameters

fileName String

Name of input file

Return Value

String
Message digest in hex format

Remarks

Use when comparing text data on a Unix system

See Also

Md5 Class
CryptoSysAPI Namespace

Md5.HexDigest Method

Computes final message digest in hex format

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public string HexDigest()

Return Value

String
Digest in hex format

See Also

Md5 Class
CryptoSysAPI Namespace

Md5.HexHash(Byte[]) Method

Creates message digest in hex format from message in byte array

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
HexHash(Byte[]) Creates message digest in hex format from message in byte array
HexHash(String) Creates message digest in hex format from message in Ansi string

Syntax

public static string HexHash(
    byte[] message
)

Parameters

message Byte[]

Message data to be digested

Return Value

String
Digest in hex format

See Also

Md5 Class
CryptoSysAPI Namespace

Md5.HexHash(String) Method

Creates message digest in hex format from message in Ansi string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
HexHash(Byte[]) Creates message digest in hex format from message in byte array
HexHash(String) Creates message digest in hex format from message in Ansi string

Syntax

public static string HexHash(
    string message
)

Parameters

message String

Message text to be digested

Return Value

String
Digest in hex format

See Also

Md5 Class
CryptoSysAPI Namespace

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

Computes the keyed hash digest of binary data using HMAC algorithm

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Hmac(Byte[], Byte[]) Computes the keyed hash digest of binary data using HMAC algorithm
Hmac(String, String) Computes the keyed hash digest using HMAC algorithm passing data as hex strings

Syntax

public static string Hmac(
    byte[] data,
    byte[] key
)

Parameters

data Byte[]

Data in array of bytes

key Byte[]

Key in array of bytes

Return Value

String
Digest in hex format

See Also

Md5 Class
CryptoSysAPI Namespace

Md5.Hmac(String, String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Hmac(Byte[], Byte[]) Computes the keyed hash digest of binary data using HMAC algorithm
Hmac(String, String) Computes the keyed hash digest using HMAC algorithm passing data as hex strings

Syntax

public static string Hmac(
    string dataHex,
    string keyHex
)

Parameters

dataHex String

Data in hex format

keyHex String

Key in hex format

Return Value

String
Digest in hex format

See Also

Md5 Class
CryptoSysAPI Namespace

Md5.Init Method

Initializes the context

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public bool Init()

Return Value

Boolean
True if successful, False if failed

See Also

Md5 Class
CryptoSysAPI Namespace

Md5.Instance Method

Create the one and only instance

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static Md5 Instance()

Return Value

Md5
Single instance to class

See Also

Md5 Class
CryptoSysAPI Namespace

Md5.Reset Method

Resets the context

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int Reset()

Return Value

Int32
0 on success or a nonzero error code

See Also

Md5 Class
CryptoSysAPI Namespace

Pbe Class

Password-based encryption

Inheritance Hierarchy

System.Object
CryptoSysAPI.Pbe

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Pbe

The Pbe type exposes the following members.

Methods

Name Description
Kdf2(Int32, Byte[], Byte[], Int32, HashAlgorithm) Derives a key of any length from a password using the PBKDF2 algorithm using specified HMAC algorithm
Kdf2(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
Scrypt(Int32, Byte[], Byte[], Int32, Int32, Int32) Derives a key of any length from a password using the SCRYPT algorithm.
Scrypt(Int32, String, String, Int32, Int32, Int32) Derives a key in hex format from a password with the salt in hex format

Remarks

Password-based encryption

See Also

CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Kdf2(Int32, Byte[], Byte[], Int32, HashAlgorithm) Derives a key of any length from a password using the PBKDF2 algorithm using specified HMAC algorithm
Kdf2(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

public static byte[] Kdf2(
    int dkLen,
    byte[] pwdBytes,
    byte[] salt,
    int count,
    HashAlgorithm hashAlg = HashAlgorithm.Sha1
)

Parameters

dkLen Int32

Required length of key in bytes

pwdBytes Byte[]

Password encoded in byte format

salt Byte[]

Salt in byte format

count Int32

Iteration count

hashAlg HashAlgorithm (Optional)

Hash algorithm to use in HMAC PRF (optional, default=SHA-1)

Return Value

Byte[]
Key in byte[] format

See Also

Pbe Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Kdf2(Int32, Byte[], Byte[], Int32, HashAlgorithm) Derives a key of any length from a password using the PBKDF2 algorithm using specified HMAC algorithm
Kdf2(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

public static string Kdf2(
    int dkLen,
    string pwdStr,
    string saltHex,
    int count,
    HashAlgorithm hashAlg = HashAlgorithm.Sha1
)

Parameters

dkLen Int32

Required length of key in bytes

pwdStr String

Password

saltHex String

Salt in hex format

count Int32

Iteration count

hashAlg HashAlgorithm (Optional)

Hash algorithm to use in HMAC PRF (optional, default=SHA-1)

Return Value

String
Key in hex format

Remarks

Password pwdStr is normal text, not hexadecimal

Example

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

See Also

Pbe Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Scrypt(Int32, Byte[], Byte[], Int32, Int32, Int32) Derives a key of any length from a password using the SCRYPT algorithm.
Scrypt(Int32, String, String, Int32, Int32, Int32) Derives a key in hex format from a password with the salt in hex format

Syntax

public static byte[] Scrypt(
    int dkLen,
    byte[] pwdBytes,
    byte[] salt,
    int N,
    int r,
    int p
)

Parameters

dkLen Int32

Required length of key in bytes

pwdBytes Byte[]

Password encoded in byte format

salt Byte[]

Salt in byte format

N Int32

CPU/Memory cost parameter, a number greater than one and a power of 2.

r Int32

Block size r

p Int32

Parallelization parameter p

Return Value

Byte[]
Key in byte[] format

See Also

Pbe Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Scrypt(Int32, Byte[], Byte[], Int32, Int32, Int32) Derives a key of any length from a password using the SCRYPT algorithm.
Scrypt(Int32, String, String, Int32, Int32, Int32) Derives a key in hex format from a password with the salt in hex format

Syntax

public static string Scrypt(
    int dkLen,
    string pwdStr,
    string saltHex,
    int N,
    int r,
    int p
)

Parameters

dkLen Int32

Required length of key in bytes

pwdStr String

Password (normal text)

saltHex String

Salt in hex format

N Int32

CPU/Memory cost parameter, a number greater than one and a power of 2.

r Int32

Block size r

p Int32

Parallelization parameter p

Return Value

String
Key in hex format

Remarks

Password pwdStr is normal text, not hexadecimal

Example

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

See Also

Pbe Class
CryptoSysAPI Namespace

Pc1 Class

RC4-compatible stream cipher algorithm (superseded by Cipher.Stream methods)

Inheritance Hierarchy

System.Object
CryptoSysAPI.Pc1

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Pc1

The Pc1 type exposes the following members.

Methods

Name Description
Encrypt(Byte[], Byte[]) Encrypt byte array input using RC4-compatible algorithm
Encrypt(String, String) Encrypt hex-encoded input using RC4-compatible algorithm
File Encrypt a file using RC4-compatible algorithm

See Also

CryptoSysAPI Namespace

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

Encrypt byte array input using RC4-compatible algorithm

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[]) Encrypt byte array input using RC4-compatible algorithm
Encrypt(String, String) Encrypt hex-encoded input using RC4-compatible algorithm

Syntax

public static byte[] Encrypt(
    byte[] input,
    byte[] key
)

Parameters

input Byte[]

input byte array, any length

key Byte[]

key byte array, any length

Return Value

Byte[]
byte array

Remarks

Superseded by Cipher.StreamBytes()

See Also

Pc1 Class
CryptoSysAPI Namespace

Pc1.Encrypt(String, String) Method

Encrypt hex-encoded input using RC4-compatible algorithm

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[]) Encrypt byte array input using RC4-compatible algorithm
Encrypt(String, String) Encrypt hex-encoded input using RC4-compatible algorithm

Syntax

public static string Encrypt(
    string inputHex,
    string keyHex
)

Parameters

inputHex String

hex-encoded input, any length

keyHex String

hex-encoded key, any length

Return Value

String
hex-encoded string

Remarks

Superseded by Cipher.StreamHex()

See Also

Pc1 Class
CryptoSysAPI Namespace

Pc1.File Method

Encrypt a file using RC4-compatible algorithm

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static int File(
    string fileOut,
    string fileIn,
    byte[] key
)

Parameters

fileOut String

Full pathname of output file to be created. Must be different from fileIn

fileIn String

Full pathname of input file

key Byte[]

Key byte array, any length

Return Value

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

Remarks

Superseded by Cipher.StreamFile()

See Also

Pc1 Class
CryptoSysAPI Namespace

Prf Class

Pseudorandom function (PRF) methods.

Inheritance Hierarchy

System.Object
CryptoSysAPI.Prf

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Prf

The Prf type exposes the following members.

Methods

Name Description
Bytes Generate output bytes using a pseudorandom function (PRF).

See Also

CryptoSysAPI Namespace

Prf.Bytes Method

Generate output bytes using a pseudorandom function (PRF).

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] Bytes(
    int numBytes,
    byte[] message,
    byte[] key,
    string customStr,
    PrfAlgorithm prfAlg
)

Parameters

numBytes Int32

Required number of output bytes.

message Byte[]

Input message data.

key Byte[]

Key.

customStr String

Customization string (optional).

prfAlg PrfAlgorithm

PRF algorithm.

Return Value

Byte[]
Output data in byte array.

See Also

Prf Class
CryptoSysAPI Namespace

Rng Class

Random Number Generator to NIST SP800-90

Inheritance Hierarchy

System.Object
CryptoSysAPI.Rng

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Rng

The Rng type exposes the following members.

Methods

Name Description
BytesWithPrompt(Int32, Rng.Strength) Generates an array of random bytes with a prompt for keyboard input
BytesWithPrompt(Int32, String, Rng.Strength) Generates an array of random bytes with a prompt for keyboard input
HexWithPrompt(Int32) Generates random bytes in hex format with a prompt for keyboard input
HexWithPrompt(Int32, String, Rng.Strength) Generates random bytes in hex format with a prompt for keyboard input
Initialize Initialize the RNG generator with a seed file.
InitializeEx Query and initialize the RNG generator using Intel(R) DRNG, if available.
KeyBytes(Int32, Byte[]) Generates a random key with user-supplied entropy
KeyBytes(Int32, String) Generates a random key
KeyHex(Int32, Byte[]) Generates a random key in hex format with user-supplied entropy
KeyHex(Int32, String) Generates a random key in hex format
MakeSeedFile(String, Rng.Strength) Create a new seed file suitable for use with Rng.Initialize
MakeSeedFile(String, String, Rng.Strength) Create a new seed file suitable for use with Rng.Initialize
NonceBytes Generates a random nonce
NonceHex Generates a random nonce in hex format
Number Generates a random integer in a given range
Octet Generates a single random octet (byte)
Test Carries out a NIST SP800-90 health check and FIPS140-2 statistical tests on the random number generator
TestDrbgvs 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).
UpdateSeedFile Updates the RNG seed file

See Also

CryptoSysAPI Namespace

Rng.BytesWithPrompt(Int32, Rng.Strength) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
BytesWithPrompt(Int32, Rng.Strength) Generates an array of random bytes with a prompt for keyboard input
BytesWithPrompt(Int32, String, Rng.Strength) Generates an array of random bytes with a prompt for keyboard input

Syntax

public static byte[] BytesWithPrompt(
    int numBytes,
    Rng.Strength strength = Rng.Strength.Default
)

Parameters

numBytes Int32

Required number of random bytes

strength Rng.Strength (Optional)

Required security strength (default=112 bits)

Return Value

Byte[]
Array of random bytes

See Also

Rng Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
BytesWithPrompt(Int32, Rng.Strength) Generates an array of random bytes with a prompt for keyboard input
BytesWithPrompt(Int32, String, Rng.Strength) Generates an array of random bytes with a prompt for keyboard input

Syntax

public static byte[] BytesWithPrompt(
    int numBytes,
    string prompt,
    Rng.Strength strength
)

Parameters

numBytes Int32

Required number of random bytes

prompt String

Alternative prompt. Set as an empty string "" for the default prompt.

strength Rng.Strength

Required security strength

Return Value

Byte[]
Array of random bytes

See Also

Rng Class
CryptoSysAPI Namespace

Rng.HexWithPrompt(Int32) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
HexWithPrompt(Int32) Generates random bytes in hex format with a prompt for keyboard input
HexWithPrompt(Int32, String, Rng.Strength) Generates random bytes in hex format with a prompt for keyboard input

Syntax

public static string HexWithPrompt(
    int numBytes
)

Parameters

numBytes Int32

Required number of random bytes

Return Value

String
Random bytes in hex format

See Also

Rng Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
HexWithPrompt(Int32) Generates random bytes in hex format with a prompt for keyboard input
HexWithPrompt(Int32, String, Rng.Strength) Generates random bytes in hex format with a prompt for keyboard input

Syntax

public static string HexWithPrompt(
    int numBytes,
    string prompt,
    Rng.Strength strength
)

Parameters

numBytes Int32

Required number of random bytes

prompt String

Alternative prompt. Set as an empty string "" for the default prompt.

strength Rng.Strength

Required security strength

Return Value

String
Random bytes in hex format

See Also

Rng Class
CryptoSysAPI Namespace

Rng.Initialize Method

Initialize the RNG generator with a seed file.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static bool Initialize(
    string seedFile
)

Parameters

seedFile String

Full path name of seed file

Return Value

Boolean
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).

See Also

Rng Class
CryptoSysAPI Namespace

Rng.InitializeEx Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static int InitializeEx(
    Rng.Options opts = Rng.Options.Default
)

Parameters

opts Rng.Options (Optional)

Specify Rng.Options.NoIntelDrng to explicitly turn off support.

Return Value

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

See Also

Rng Class
CryptoSysAPI Namespace

Rng.KeyBytes(Int32, Byte[]) Method

Generates a random key with user-supplied entropy

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
KeyBytes(Int32, Byte[]) Generates a random key with user-supplied entropy
KeyBytes(Int32, String) Generates a random key

Syntax

public static byte[] KeyBytes(
    int numBytes,
    byte[] arrSeed
)

Parameters

numBytes Int32

Required number of random bytes

arrSeed Byte[]

User-supplied entropy in byte format

Return Value

Byte[]
Array of random bytes

See Also

Rng Class
CryptoSysAPI Namespace

Rng.KeyBytes(Int32, String) Method

Generates a random key

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
KeyBytes(Int32, Byte[]) Generates a random key with user-supplied entropy
KeyBytes(Int32, String) Generates a random key

Syntax

public static byte[] KeyBytes(
    int numBytes,
    string seedStr = ""
)

Parameters

numBytes Int32

Required number of random bytes

seedStr String (Optional)

User-supplied entropy in string format. Set as an empty string "" to ignore.

Return Value

Byte[]
Array of random bytes

See Also

Rng Class
CryptoSysAPI Namespace

Rng.KeyHex(Int32, Byte[]) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
KeyHex(Int32, Byte[]) Generates a random key in hex format with user-supplied entropy
KeyHex(Int32, String) Generates a random key in hex format

Syntax

public static string KeyHex(
    int numBytes,
    byte[] arrSeed
)

Parameters

numBytes Int32

Required number of random bytes

arrSeed Byte[]

User-supplied entropy in byte format

Return Value

String
Random bytes in hex format

See Also

Rng Class
CryptoSysAPI Namespace

Rng.KeyHex(Int32, String) Method

Generates a random key in hex format

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
KeyHex(Int32, Byte[]) Generates a random key in hex format with user-supplied entropy
KeyHex(Int32, String) Generates a random key in hex format

Syntax

public static string KeyHex(
    int numBytes,
    string seedStr = ""
)

Parameters

numBytes Int32

Required number of random bytes

seedStr String (Optional)

User-supplied entropy in string format. Set as an empty string "" to ignore.

Return Value

String
Random bytes in hex format

See Also

Rng Class
CryptoSysAPI Namespace

Rng.MakeSeedFile(String, Rng.Strength) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
MakeSeedFile(String, Rng.Strength) Create a new seed file suitable for use with Rng.Initialize
MakeSeedFile(String, String, Rng.Strength) Create a new seed file suitable for use with Rng.Initialize

Syntax

public static bool MakeSeedFile(
    string seedFile,
    Rng.Strength strength = Rng.Strength.Default
)

Parameters

seedFile String

Name of seed file to be created

strength Rng.Strength (Optional)

Required security strength (default=112 bits)

Return Value

Boolean
true if successful; false if fails

Remarks

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

See Also

Rng Class
CryptoSysAPI Namespace

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

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
MakeSeedFile(String, Rng.Strength) Create a new seed file suitable for use with Rng.Initialize
MakeSeedFile(String, String, Rng.Strength) Create a new seed file suitable for use with Rng.Initialize

Syntax

public static bool MakeSeedFile(
    string seedFile,
    string prompt,
    Rng.Strength strength
)

Parameters

seedFile String

Name of seed file to be created

prompt String

Prompt for dialog

strength Rng.Strength

Required security strength

Return Value

Boolean
true if successful; false if fails

Remarks

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

See Also

Rng Class
CryptoSysAPI Namespace

Rng.NonceBytes Method

Generates a random nonce

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] NonceBytes(
    int numBytes
)

Parameters

numBytes Int32

Number of bytes required

Return Value

Byte[]
Array of bytes

See Also

Rng Class
CryptoSysAPI Namespace

Rng.NonceHex Method

Generates a random nonce in hex format

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string NonceHex(
    int numBytes
)

Parameters

numBytes Int32

Number of bytes required

Return Value

String
Nonce in hex format

See Also

Rng Class
CryptoSysAPI Namespace

Rng.Number Method

Generates a random integer in a given range

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static int Number(
    int lower,
    int upper
)

Parameters

lower Int32

lower value of range

upper Int32

upper value of range

Return Value

Int32
Random integer

See Also

Rng Class
CryptoSysAPI Namespace

Rng.Octet Method

Generates a single random octet (byte)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte Octet()

Return Value

Byte
Single byte value randomly chosen between 0 and 255

See Also

Rng Class
CryptoSysAPI Namespace

Rng.Test Method

Carries out a NIST SP800-90 health check and FIPS140-2 statistical tests on the random number generator

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static bool Test(
    string resultFile
)

Parameters

resultFile String

Name of results file to be created, or null/Nothing not to create a results file.

Return Value

Boolean
true if successful; false if fails.

Remarks

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

See Also

Rng Class
CryptoSysAPI Namespace

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).

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string TestDrbgvs(
    int returnedBitsLen,
    string entropyInput,
    string nonce,
    string personalizationString,
    string additionalInput1,
    string entropyReseed,
    string additionalInputReseed,
    string additionalInput2
)

Parameters

returnedBitsLen Int32

Number of bits to be returned from each call to the generate function in the test

entropyInput String

the EntropyInput value in hex format

nonce String

the Nonce value in hex format

personalizationString String

the PersonalizationString value in hex format

additionalInput1 String

the first AdditionalInput value in hex format

entropyReseed String

the EntropyReseed value in hex format

additionalInputReseed String

the AdditionalInputReseed value in hex format

additionalInput2 String

the second AdditionalInput value in hex format

Return Value

String
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.

See Also

Rng Class
CryptoSysAPI Namespace

Rng.UpdateSeedFile Method

Updates the RNG seed file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static bool UpdateSeedFile(
    string seedFile
)

Parameters

seedFile String

Full path name of seed file

Return Value

Boolean
true if successful; false if fails

Remarks

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

See Also

Rng Class
CryptoSysAPI Namespace

Sha1 Class

Secure Hash Algorithm 1 (SHA-1)

Inheritance Hierarchy

System.Object
CryptoSysAPI.Sha1

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Sha1

The Sha1 type exposes the following members.

Properties

Name Description
ErrCode Last error code (for Init, AddData and HexDigest methods only)

Methods

Name Description
AddData(Byte[]) Adds an array of 8-bit bytes to the digest
AddData(String) Adds a string of Ansi characters to the digest
BytesHash Creates message digest as array of bytes from message in byte array
Dispose Dispose of this object and clear any stored data
FileHexHash Creates hash digest of a binary file
FileTextHexHash Creates hash digest of a “text” file treating CR-LF pairs as a single newline char
HexDigest Computes final message digest in hex format
HexHash(Byte[]) Creates message digest in hex format from message in byte array
HexHash(String) Creates message digest in hex format from message in Ansi string
Hmac(Byte[], Byte[]) Computes the keyed hash digest of binary data using HMAC algorithm
Hmac(String, String) Computes the keyed hash digest using HMAC algorithm passing data as hex strings
Init Initializes the context
Instance Create the one and only instance
Reset Resets the context

See Also

CryptoSysAPI Namespace

Sha1.ErrCode Property

Last error code (for Init, AddData and HexDigest methods only)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int ErrCode { get; }

Property Value

Int32

See Also

Sha1 Class
CryptoSysAPI Namespace

Sha1.AddData(Byte[]) Method

Adds an array of 8-bit bytes to the digest

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
AddData(Byte[]) Adds an array of 8-bit bytes to the digest
AddData(String) Adds a string of Ansi characters to the digest

Syntax

public int AddData(
    byte[] b
)

Parameters

b Byte[]

Data to add

Return Value

Int32
0 on success or nonzero error code

See Also

Sha1 Class
CryptoSysAPI Namespace

Sha1.AddData(String) Method

Adds a string of Ansi characters to the digest

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
AddData(Byte[]) Adds an array of 8-bit bytes to the digest
AddData(String) Adds a string of Ansi characters to the digest

Syntax

public int AddData(
    string s
)

Parameters

s String

String of Ansi characters

Return Value

Int32
0 on success or nonzero error code

See Also

Sha1 Class
CryptoSysAPI Namespace

Sha1.BytesHash Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] BytesHash(
    byte[] message
)

Parameters

message Byte[]

Message data to be digested

Return Value

Byte[]
Digest in array of bytes

See Also

Sha1 Class
CryptoSysAPI Namespace

Sha1.Dispose Method

Dispose of this object and clear any stored data

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public void Dispose()

See Also

Sha1 Class
CryptoSysAPI Namespace

Sha1.FileHexHash Method

Creates hash digest of a binary file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string FileHexHash(
    string fileName
)

Parameters

fileName String

Name of input file

Return Value

String
Message digest in hex format

See Also

Sha1 Class
CryptoSysAPI Namespace

Sha1.FileTextHexHash Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string FileTextHexHash(
    string fileName
)

Parameters

fileName String

Name of input file

Return Value

String
Message digest in hex format

Remarks

Use when comparing text data on a Unix system

See Also

Sha1 Class
CryptoSysAPI Namespace

Sha1.HexDigest Method

Computes final message digest in hex format

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public string HexDigest()

Return Value

String
Digest in hex format

See Also

Sha1 Class
CryptoSysAPI Namespace

Sha1.HexHash(Byte[]) Method

Creates message digest in hex format from message in byte array

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
HexHash(Byte[]) Creates message digest in hex format from message in byte array
HexHash(String) Creates message digest in hex format from message in Ansi string

Syntax

public static string HexHash(
    byte[] message
)

Parameters

message Byte[]

Message data to be digested

Return Value

String
Digest in hex format

See Also

Sha1 Class
CryptoSysAPI Namespace

Sha1.HexHash(String) Method

Creates message digest in hex format from message in Ansi string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
HexHash(Byte[]) Creates message digest in hex format from message in byte array
HexHash(String) Creates message digest in hex format from message in Ansi string

Syntax

public static string HexHash(
    string message
)

Parameters

message String

Message text to be digested

Return Value

String
Digest in hex format

See Also

Sha1 Class
CryptoSysAPI Namespace

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

Computes the keyed hash digest of binary data using HMAC algorithm

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Hmac(Byte[], Byte[]) Computes the keyed hash digest of binary data using HMAC algorithm
Hmac(String, String) Computes the keyed hash digest using HMAC algorithm passing data as hex strings

Syntax

public static string Hmac(
    byte[] data,
    byte[] key
)

Parameters

data Byte[]

Data in array of bytes

key Byte[]

Key in array of bytes

Return Value

String
Digest in hex format

See Also

Sha1 Class
CryptoSysAPI Namespace

Sha1.Hmac(String, String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Hmac(Byte[], Byte[]) Computes the keyed hash digest of binary data using HMAC algorithm
Hmac(String, String) Computes the keyed hash digest using HMAC algorithm passing data as hex strings

Syntax

public static string Hmac(
    string dataHex,
    string keyHex
)

Parameters

dataHex String

Data in hex format

keyHex String

Key in hex format

Return Value

String
Digest in hex format

See Also

Sha1 Class
CryptoSysAPI Namespace

Sha1.Init Method

Initializes the context

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public bool Init()

Return Value

Boolean
True if successful, False if failed

See Also

Sha1 Class
CryptoSysAPI Namespace

Sha1.Instance Method

Create the one and only instance

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static Sha1 Instance()

Return Value

Sha1
Single instance to class

See Also

Sha1 Class
CryptoSysAPI Namespace

Sha1.Reset Method

Resets the context

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int Reset()

Return Value

Int32
0 on success or a nonzero error code

See Also

Sha1 Class
CryptoSysAPI Namespace

Sha256 Class

Secure Hash 256 Algorithm (SHA-256)

Inheritance Hierarchy

System.Object
CryptoSysAPI.Sha256

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Sha256

The Sha256 type exposes the following members.

Properties

Name Description
ErrCode Last error code (for Init, AddData and HexDigest methods only)

Methods

Name Description
AddData(Byte[]) Adds an array of 8-bit bytes to the digest
AddData(String) Adds a string of Ansi characters to the digest
BytesHash Creates message digest as array of bytes from message in byte array
Dispose Dispose of this object and clear any stored data
FileHexHash Creates hash digest of a binary file
FileTextHexHash Creates hash digest of a “text” file treating CR-LF pairs as a single newline char
HexDigest Computes final message digest in hex format
HexHash(Byte[]) Creates message digest in hex format from message in byte array
HexHash(String) Creates message digest in hex format from message in Ansi string
Hmac(Byte[], Byte[]) Computes the keyed hash digest of binary data using HMAC algorithm
Hmac(String, String) Computes the keyed hash digest using HMAC algorithm passing data as hex strings
Init Initializes the context
Instance Create the one and only instance
Reset Resets the context

See Also

CryptoSysAPI Namespace

Sha256.ErrCode Property

Last error code (for Init, AddData and HexDigest methods only)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int ErrCode { get; }

Property Value

Int32

See Also

Sha256 Class
CryptoSysAPI Namespace

Sha256.AddData(Byte[]) Method

Adds an array of 8-bit bytes to the digest

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
AddData(Byte[]) Adds an array of 8-bit bytes to the digest
AddData(String) Adds a string of Ansi characters to the digest

Syntax

public int AddData(
    byte[] b
)

Parameters

b Byte[]

Data to add

Return Value

Int32
0 on success or nonzero error code

See Also

Sha256 Class
CryptoSysAPI Namespace

Sha256.AddData(String) Method

Adds a string of Ansi characters to the digest

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
AddData(Byte[]) Adds an array of 8-bit bytes to the digest
AddData(String) Adds a string of Ansi characters to the digest

Syntax

public int AddData(
    string s
)

Parameters

s String

String of Ansi characters

Return Value

Int32
0 on success or nonzero error code

See Also

Sha256 Class
CryptoSysAPI Namespace

Sha256.BytesHash Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] BytesHash(
    byte[] message
)

Parameters

message Byte[]

Message data to be digested

Return Value

Byte[]
Digest in array of bytes

See Also

Sha256 Class
CryptoSysAPI Namespace

Sha256.Dispose Method

Dispose of this object and clear any stored data

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public void Dispose()

See Also

Sha256 Class
CryptoSysAPI Namespace

Sha256.FileHexHash Method

Creates hash digest of a binary file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string FileHexHash(
    string fileName
)

Parameters

fileName String

Name of input file

Return Value

String
Message digest in hex format

See Also

Sha256 Class
CryptoSysAPI Namespace

Sha256.FileTextHexHash Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static string FileTextHexHash(
    string fileName
)

Parameters

fileName String

Name of input file

Return Value

String
Message digest in hex format

Remarks

Use when comparing text data on a Unix system

See Also

Sha256 Class
CryptoSysAPI Namespace

Sha256.HexDigest Method

Computes final message digest in hex format

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public string HexDigest()

Return Value

String
Digest in hex format

See Also

Sha256 Class
CryptoSysAPI Namespace

Sha256.HexHash(Byte[]) Method

Creates message digest in hex format from message in byte array

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
HexHash(Byte[]) Creates message digest in hex format from message in byte array
HexHash(String) Creates message digest in hex format from message in Ansi string

Syntax

public static string HexHash(
    byte[] message
)

Parameters

message Byte[]

Message data to be digested

Return Value

String
Digest in hex format

See Also

Sha256 Class
CryptoSysAPI Namespace

Sha256.HexHash(String) Method

Creates message digest in hex format from message in Ansi string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
HexHash(Byte[]) Creates message digest in hex format from message in byte array
HexHash(String) Creates message digest in hex format from message in Ansi string

Syntax

public static string HexHash(
    string message
)

Parameters

message String

Message text to be digested

Return Value

String
Digest in hex format

See Also

Sha256 Class
CryptoSysAPI Namespace

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

Computes the keyed hash digest of binary data using HMAC algorithm

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Hmac(Byte[], Byte[]) Computes the keyed hash digest of binary data using HMAC algorithm
Hmac(String, String) Computes the keyed hash digest using HMAC algorithm passing data as hex strings

Syntax

public static string Hmac(
    byte[] data,
    byte[] key
)

Parameters

data Byte[]

Data in array of bytes

key Byte[]

Key in array of bytes

Return Value

String
Digest in hex format

See Also

Sha256 Class
CryptoSysAPI Namespace

Sha256.Hmac(String, String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Hmac(Byte[], Byte[]) Computes the keyed hash digest of binary data using HMAC algorithm
Hmac(String, String) Computes the keyed hash digest using HMAC algorithm passing data as hex strings

Syntax

public static string Hmac(
    string dataHex,
    string keyHex
)

Parameters

dataHex String

Data in hex format

keyHex String

Key in hex format

Return Value

String
Digest in hex format

See Also

Sha256 Class
CryptoSysAPI Namespace

Sha256.Init Method

Initializes the context

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public bool Init()

Return Value

Boolean
True if successful, False if failed

See Also

Sha256 Class
CryptoSysAPI Namespace

Sha256.Instance Method

Create the one and only instance

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static Sha256 Instance()

Return Value

Sha256
Single instance to class

See Also

Sha256 Class
CryptoSysAPI Namespace

Sha256.Reset Method

Resets the context

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int Reset()

Return Value

Int32
0 on success or a nonzero error code

See Also

Sha256 Class
CryptoSysAPI Namespace

Sha3 Class

Secure Hash Algorithm SHA-3

Inheritance Hierarchy

System.Object
CryptoSysAPI.Sha3

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Sha3

The Sha3 type exposes the following members.

Properties

Name Description
ErrCode Last error code (for Init, AddData and HexDigest methods only)
LengthInBytes Length in bytes of hash output (i.e. length in bits / 8)

Methods

Name Description
AddData(Byte[]) Adds an array of 8-bit bytes to the digest
AddData(String) Adds a string of Ansi characters to the digest
Dispose Dispose of this object and clear any stored data
HexDigest Computes final message digest in hex format
Init Initialises the object ready to receive data to digest
Instance Create the one and only instance
Reset Resets the context

See Also

CryptoSysAPI Namespace

Sha3.ErrCode Property

Last error code (for Init, AddData and HexDigest methods only)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int ErrCode { get; }

Property Value

Int32

See Also

Sha3 Class
CryptoSysAPI Namespace

Sha3.LengthInBytes Property

Length in bytes of hash output (i.e. length in bits / 8)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int LengthInBytes { get; }

Property Value

Int32

See Also

Sha3 Class
CryptoSysAPI Namespace

Sha3.AddData(Byte[]) Method

Adds an array of 8-bit bytes to the digest

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
AddData(Byte[]) Adds an array of 8-bit bytes to the digest
AddData(String) Adds a string of Ansi characters to the digest

Syntax

public int AddData(
    byte[] b
)

Parameters

b Byte[]

Data to add

Return Value

Int32
0 on success or nonzero error code

See Also

Sha3 Class
CryptoSysAPI Namespace

Sha3.AddData(String) Method

Adds a string of Ansi characters to the digest

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
AddData(Byte[]) Adds an array of 8-bit bytes to the digest
AddData(String) Adds a string of Ansi characters to the digest

Syntax

public int AddData(
    string s
)

Parameters

s String

String of Ansi characters

Return Value

Int32
0 on success or nonzero error code

See Also

Sha3 Class
CryptoSysAPI Namespace

Sha3.Dispose Method

Dispose of this object and clear any stored data

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public void Dispose()

See Also

Sha3 Class
CryptoSysAPI Namespace

Sha3.HexDigest Method

Computes final message digest in hex format

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public string HexDigest()

Return Value

String
Digest in hex format

See Also

Sha3 Class
CryptoSysAPI Namespace

Sha3.Init Method

Initialises the object ready to receive data to digest

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public bool Init(
    int hashBitLen
)

Parameters

hashBitLen Int32

Size of SHA-3 algorithm in bits. Must be one of {224, 256, 384, 512}.

Return Value

Boolean
True if successful, False if failed

See Also

Sha3 Class
CryptoSysAPI Namespace

Sha3.Instance Method

Create the one and only instance

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static Sha3 Instance()

Return Value

Sha3
Single instance to class

See Also

Sha3 Class
CryptoSysAPI Namespace

Sha3.Reset Method

Resets the context

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int Reset()

Return Value

Int32
0 on success or a nonzero error code

See Also

Sha3 Class
CryptoSysAPI Namespace

Tdea Class

Triple DES Cipher (3DES, TDEA, DES-EDE3)

Inheritance Hierarchy

System.Object
CryptoSysAPI.Tdea

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Tdea : IDisposable

The Tdea type exposes the following members.

Properties

Name Description
ErrCode Last error code (for Init and Update methods only)

Methods

Name Description
CheckKey(Byte[]) Verifies that no part of the key is a weak or semi-weak TDEA key.
CheckKey(String) Verifies that no part of the key is a weak or semi-weak TDEA key.
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string
Dispose Dispose of this object and clear any key schedules
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting
Instance Create the one and only instance
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction
Update(String) Transform hex string data with previously initialized key, mode and direction

Fields

Name Description
BlockSize Block size in bytes

See Also

CryptoSysAPI Namespace

Tdea.ErrCode Property

Last error code (for Init and Update methods only)

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public int ErrCode { get; }

Property Value

Int32

See Also

Tdea Class
CryptoSysAPI Namespace

Tdea.CheckKey(Byte[]) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
CheckKey(Byte[]) Verifies that no part of the key is a weak or semi-weak TDEA key.
CheckKey(String) Verifies that no part of the key is a weak or semi-weak TDEA key.

Syntax

public static int CheckKey(
    byte[] key
)

Parameters

key Byte[]

Key to check

Return Value

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

See Also

Tdea Class
CryptoSysAPI Namespace

Tdea.CheckKey(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
CheckKey(Byte[]) Verifies that no part of the key is a weak or semi-weak TDEA key.
CheckKey(String) Verifies that no part of the key is a weak or semi-weak TDEA key.

Syntax

public static int CheckKey(
    string keyHex
)

Parameters

keyHex String

Hex-encoded key to check

Return Value

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

See Also

Tdea Class
CryptoSysAPI Namespace

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

Decrypt data in byte array

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static byte[] Decrypt(
    byte[] input,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

input Byte[]

Input data

key Byte[]

Key of exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Byte[]
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)

See Also

Tdea Class
CryptoSysAPI Namespace

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

Decrypt hex-encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static string Decrypt(
    string inputHex,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

inputHex String

Hex-encoded input data

keyHex String

Hex-encoded key representing exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV representing exactly 8 bytes or "" for ECB mode

Return Value

String
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)

See Also

Tdea Class
CryptoSysAPI Namespace

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

Decrypt encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Decrypt(Byte[], Byte[], Mode, Byte[]) Decrypt data in byte array
Decrypt(String, String, Mode, String) Decrypt hex-encoded data string
Decrypt(String, String, Mode, String, EncodingBase) Decrypt encoded data string

Syntax

public static string Decrypt(
    string inputStr,
    string keyStr,
    Mode mode,
    string ivStr,
    EncodingBase encodingBase
)

Parameters

inputStr String

Encoded input data

keyStr String

Encoded key representing exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

ivStr String

Encoded IV representing exactly 8 bytes or "" for ECB mode

encodingBase EncodingBase

Type of encoding used

Return Value

String
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)

See Also

Tdea Class
CryptoSysAPI Namespace

Tdea.Dispose Method

Dispose of this object and clear any key schedules

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public void Dispose()

Implements

IDisposable.Dispose()

See Also

Tdea Class
CryptoSysAPI Namespace

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

Encrypt data in byte array

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static byte[] Encrypt(
    byte[] input,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

input Byte[]

Input data

key Byte[]

Key of exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

Byte[]
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)

See Also

Tdea Class
CryptoSysAPI Namespace

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

Encrypt hex-encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static string Encrypt(
    string inputHex,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

inputHex String

Hex-encoded input data

keyHex String

Hex-encoded key representing exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV representing exactly 8 bytes or "" for ECB mode

Return Value

String
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)

See Also

Tdea Class
CryptoSysAPI Namespace

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

Encrypt encoded data string

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Encrypt(Byte[], Byte[], Mode, Byte[]) Encrypt data in byte array
Encrypt(String, String, Mode, String) Encrypt hex-encoded data string
Encrypt(String, String, Mode, String, EncodingBase) Encrypt encoded data string

Syntax

public static string Encrypt(
    string inputStr,
    string keyStr,
    Mode mode,
    string ivStr,
    EncodingBase encodingBase
)

Parameters

inputStr String

Encoded input data

keyStr String

Encoded key representing exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

ivStr String

Encoded IV representing exactly 8 bytes or "" for ECB mode

encodingBase EncodingBase

Type of encoding used

Return Value

String
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)

See Also

Tdea Class
CryptoSysAPI Namespace

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

Decrypt a file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Tdea Class
CryptoSysAPI Namespace

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

Decrypt a file passing key and IV as hex strings

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

keyHex String

Hex-encoded key of exact length

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV or "" for ECB mode

Return Value

Int32
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.

See Also

Tdea Class
CryptoSysAPI Namespace

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

Decrypt a file with advanced options

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileDecrypt(String, String, Byte[], Mode, Byte[]) Decrypt a file
FileDecrypt(String, String, String, Mode, String) Decrypt a file passing key and IV as hex strings
FileDecrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Decrypt a file with advanced options

Syntax

public static int FileDecrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv,
    CipherFileOption advOptions
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes. Use null/Nothing for ECB mode or when using CipherFileOption.PrefixIV option

advOptions CipherFileOption

Advanced options. See CipherFileOption.

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Tdea Class
CryptoSysAPI Namespace

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

Encrypt a file

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Tdea Class
CryptoSysAPI Namespace

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

Encrypt a file passing key and IV as hex strings

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

keyHex String

Hex-encoded key of exact length

mode Mode

Cipher Mode

ivHex String

Hex-encoded IV or "" for ECB mode

Return Value

Int32
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.

See Also

Tdea Class
CryptoSysAPI Namespace

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

Encrypt a file with advanced options

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
FileEncrypt(String, String, Byte[], Mode, Byte[]) Encrypt a file
FileEncrypt(String, String, String, Mode, String) Encrypt a file passing key and IV as hex strings
FileEncrypt(String, String, Byte[], Mode, Byte[], CipherFileOption) Encrypt a file with advanced options

Syntax

public static int FileEncrypt(
    string fileOut,
    string fileIn,
    byte[] key,
    Mode mode,
    byte[] iv,
    CipherFileOption advOptions
)

Parameters

fileOut String

Name of output file to be created or overwritten

fileIn String

Name of input file

key Byte[]

Key of exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

advOptions CipherFileOption

Advanced options. See CipherFileOption.

Return Value

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

Remarks

fileOut and fileIn must not be the same

See Also

Tdea Class
CryptoSysAPI Namespace

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

Initializes with key, mode and IV ready to start decrypting

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

public int InitDecrypt(
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

key Byte[]

Key of exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

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

See Also

Tdea Class
CryptoSysAPI Namespace

Tdea.InitDecrypt(String, Mode, String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitDecrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start decrypting
InitDecrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start decrypting

Syntax

public int InitDecrypt(
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

keyHex String

Key in hex-encoded format

mode Mode

Cipher mode

ivHex String

IV in hex-encoded format

Return Value

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

See Also

Tdea Class
CryptoSysAPI Namespace

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

Initializes with key, mode and IV ready to start encrypting

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

public int InitEncrypt(
    byte[] key,
    Mode mode,
    byte[] iv
)

Parameters

key Byte[]

Key of exactly 24 bytes (192 bits)

mode Mode

Cipher Mode

iv Byte[]

IV of exactly 8 bytes or null/Nothing for ECB mode

Return Value

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

See Also

Tdea Class
CryptoSysAPI Namespace

Tdea.InitEncrypt(String, Mode, String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
InitEncrypt(Byte[], Mode, Byte[]) Initializes with key, mode and IV ready to start encrypting
InitEncrypt(String, Mode, String) Initializes with hex key, mode and hex IV ready to start encrypting

Syntax

public int InitEncrypt(
    string keyHex,
    Mode mode,
    string ivHex
)

Parameters

keyHex String

Key in hex-encoded format

mode Mode

Cipher mode

ivHex String

IV in hex-encoded format

Return Value

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

See Also

Tdea Class
CryptoSysAPI Namespace

Tdea.Instance Method

Create the one and only instance

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static Tdea Instance()

Return Value

Tdea
Single instance to class

See Also

Tdea Class
CryptoSysAPI Namespace

Tdea.Pad(Byte[]) Method

Pads byte array to correct length for ECB and CBC encryption

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

public static byte[] Pad(
    byte[] data
)

Parameters

data Byte[]

data to be padded

Return Value

Byte[]
padded data in byte array

Remarks

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

See Also

Tdea Class
CryptoSysAPI Namespace

Tdea.Pad(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Pad(Byte[]) Pads byte array to correct length for ECB and CBC encryption
Pad(String) Pads hex-encoded string to correct length for ECB and CBC encryption

Syntax

public static string Pad(
    string dataHex
)

Parameters

dataHex String

hex-encoded data to be padded

Return Value

String
padded data in hex-encoded string

Remarks

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

See Also

Tdea Class
CryptoSysAPI Namespace

Tdea.Unpad(Byte[]) Method

Removes the padding from an encryption block

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block

Syntax

public static byte[] Unpad(
    byte[] data
)

Parameters

data Byte[]

padded data

Return Value

Byte[]
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.

See Also

Tdea Class
CryptoSysAPI Namespace

Tdea.Unpad(String) Method

Removes the padding from a hex-encoded encryption block

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Unpad(Byte[]) Removes the padding from an encryption block
Unpad(String) Removes the padding from a hex-encoded encryption block

Syntax

public static string Unpad(
    string dataHex
)

Parameters

dataHex String

hex-encoded padded data

Return Value

String
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.

See Also

Tdea Class
CryptoSysAPI Namespace

Tdea.Update(Byte[]) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction
Update(String) Transform hex string data with previously initialized key, mode and direction

Syntax

public byte[] Update(
    byte[] data
)

Parameters

data Byte[]

input data in byte array

Return Value

Byte[]
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)

See Also

Tdea Class
CryptoSysAPI Namespace

Tdea.Update(String) Method

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

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Update(Byte[]) Transform byte input data with previously initialized key, mode and direction
Update(String) Transform hex string data with previously initialized key, mode and direction

Syntax

public string Update(
    string data
)

Parameters

data String

hex-encoded input data

Return Value

String
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)

See Also

Tdea Class
CryptoSysAPI Namespace

Tdea.BlockSize Field

Block size in bytes

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public const int BlockSize = 8

Field Value

Int32

See Also

Tdea Class
CryptoSysAPI Namespace

Wipe Class

Data Wiping Functions

Inheritance Hierarchy

System.Object
CryptoSysAPI.Wipe

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Wipe

The Wipe type exposes the following members.

Methods

Name Description
Data Zeroises data in memory
File Securely wipe and delete a file.
String Zeroises a StringBuilder

See Also

CryptoSysAPI Namespace

Wipe.Data Method

Zeroises data in memory

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static bool Data(
    byte[] data
)

Parameters

data Byte[]

data to be wiped

Return Value

Boolean
true if successful; false if fails

See Also

Wipe Class
CryptoSysAPI Namespace

Wipe.File Method

Securely wipe and delete a file.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static bool File(
    string fileName,
    Wipe.Options opts = Wipe.Options.Default
)

Parameters

fileName String

Name of file to be wiped

opts Wipe.Options (Optional)

Options (optional) Default is DOD 7-pass.

Return Value

Boolean
true if successful; false if fails

See Also

Wipe Class
CryptoSysAPI Namespace

Wipe.String Method

Zeroises a StringBuilder

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static bool String(
    StringBuilder sb
)

Parameters

sb StringBuilder

StringBuilder to be wiped

Return Value

Boolean
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.

See Also

Wipe Class
CryptoSysAPI Namespace

Xof Class

Extendable-output function (XOF) methods.

Inheritance Hierarchy

System.Object
CryptoSysAPI.Xof

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Xof

The Xof type exposes the following members.

Methods

Name Description
Bytes Generate bytes using an extendable-output function (XOF).

See Also

CryptoSysAPI Namespace

Xof.Bytes Method

Generate bytes using an extendable-output function (XOF).

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] Bytes(
    int numBytes,
    byte[] message,
    XofAlgorithm xofAlg
)

Parameters

numBytes Int32

Required number of output bytes.

message Byte[]

Input message data.

xofAlg XofAlgorithm

XOF algorithm.

Return Value

Byte[]
Output data in byte array.

See Also

Xof Class
CryptoSysAPI Namespace

Zlib Class

ZLIB compression algorithm

Inheritance Hierarchy

System.Object
CryptoSysAPI.Zlib

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public class Zlib

The Zlib type exposes the following members.

Methods

Name Description
Deflate Compress data using the ZLIB deflate algorithm
Inflate(Byte[]) Inflate compressed data using the ZLIB algorithm.
Inflate(Byte[], Int32) Inflate compressed data using the ZLIB algorithm [superseded].

Remarks

ZLIB Compression to RFC 1950

See Also

CryptoSysAPI Namespace

Zlib.Deflate Method

Compress data using the ZLIB deflate algorithm

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public static byte[] Deflate(
    byte[] dataToComp
)

Parameters

dataToComp Byte[]

Data to be compressed

Return Value

Byte[]
Compressed data

See Also

Zlib Class
CryptoSysAPI Namespace

Zlib.Inflate(Byte[]) Method

Inflate compressed data using the ZLIB algorithm.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Inflate(Byte[]) Inflate compressed data using the ZLIB algorithm.
Inflate(Byte[], Int32) Inflate compressed data using the ZLIB algorithm [superseded].

Syntax

public static byte[] Inflate(
    byte[] data
)

Parameters

data Byte[]

Compressed data to be uncompressed.

Return Value

Byte[]
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.

See Also

Zlib Class
CryptoSysAPI Namespace

Zlib.Inflate(Byte[], Int32) Method

Inflate compressed data using the ZLIB algorithm [superseded].

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Overloads

Name Description
Inflate(Byte[]) Inflate compressed data using the ZLIB algorithm.
Inflate(Byte[], Int32) Inflate compressed data using the ZLIB algorithm [superseded].

Syntax

public static byte[] Inflate(
    byte[] data,
    int lenUncompressed
)

Parameters

data Byte[]

Data to be uncompressed

lenUncompressed Int32

Length of uncompressed data

Return Value

Byte[]
Uncompressed data

Remarks

Superseded by Zlib.Inflate(Byte[])

See Also

Zlib Class
CryptoSysAPI Namespace

Aead.Algorithm Enumeration

AEAD algorithm

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public enum Algorithm

Members

Member name Description
Aes_128_Gcm AEAD_AES_128_GCM authenticated encryption algorithm (RFC 5116)
Aes_256_Gcm AEAD_AES_256_GCM authenticated encryption algorithm (RFC 5116)
Ascon_128 ASCON-128 authenticated encryption (Aead.[En/De]cryptWithTag only)
Ascon_128A ASCON-128a authenticated encryption (Aead.[En/De]cryptWithTag only)
Chacha20_Poly1305 AEAD_CHACHA20_POLY1305 authenticated encryption algorithm (RFC 7539)

See Also

CryptoSysAPI Namespace

Aead.Opts Enumeration

Advanced options

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

[FlagsAttribute]
public enum Opts

Members

Member name Description
Default Default options
PrefixIV Prefix (prepend) the IV (nonce) before the ciphertext in the output

See Also

CryptoSysAPI Namespace

Cipher.Opts Enumeration

Advanced options

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

[FlagsAttribute]
public enum Opts

Members

Member name Description
Default Default options
PrefixIV Prefix (prepend) the IV before the ciphertext in the output file (ignored for ECB mode)

See Also

CryptoSysAPI Namespace

CipherAlgorithm Enumeration

Block Cipher Algorithm

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public enum CipherAlgorithm

Members

Member name Description
Tdea Triple DES (TDEA, 3DES, des-ede3)
Aes128 AES-128
Aes192 AES-192
Aes256 AES-256

See Also

CryptoSysAPI Namespace

CipherFileOption Enumeration

Advanced options for file cipher operations

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

[FlagsAttribute]
public enum CipherFileOption

Members

Member name Description
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)

See Also

CryptoSysAPI Namespace

CipherStream.Algorithm Enumeration

Stream cipher algorithm

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public enum Algorithm

Members

Member name Description
Arcfour ARCFOUR (RC4) algorithm
Salsa20 Salsa20 algorithm
Chacha20 ChaCha20 algorithm

See Also

CryptoSysAPI Namespace

ComprAlgorithm Enumeration

Compression algorithm.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public enum ComprAlgorithm

Members

Member name Description
Zlib zlib as per RFC 1950
Zstd zstd as per RFC 8878

See Also

CryptoSysAPI Namespace

EncodingBase Enumeration

Base for encoding methods

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public enum EncodingBase

Members

Member name Description
Base64 Base64 encoding
Base16 Base16 encoding (i.e. hexadecimal)

See Also

CryptoSysAPI Namespace

HashAlgorithm Enumeration

Message Digest Hash Algorithm

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public enum HashAlgorithm

Members

Member name Description
Sha1 SHA-1 (as per FIPS PUB 180-2)
Md5 MD5 (as per RFC 1321)
Md2 MD2 (as per RFC 1319)
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)
Sha224 SHA-224 (as per FIPS PUB 180-4)
Ripemd160 RIPEMD-160
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)

See Also

CryptoSysAPI Namespace

MacAlgorithm Enumeration

Message Authentication Code (MAC) Algorithm

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public enum MacAlgorithm

Members

Member name Description
HmacSha1 HMAC-SHA-1
HmacMd5 HMAC-MD5
HmacSha256 HMAC-SHA-256
HmacSha384 HMAC-SHA-384
HmacSha512 HMAC-SHA-512
HmacSha224 HMAC-SHA-224
HmacRipemd160 HMAC-RIPEMD160
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)

See Also

CryptoSysAPI Namespace

Mode Enumeration

Cipher Mode

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public enum Mode

Members

Member name Description
ECB Electronic Code Book mode
CBC Cipher Block Chaining mode
OFB Output Feedback mode
CFB Cipher Feedback mode
CTR Counter mode

See Also

CryptoSysAPI Namespace

Padding Enumeration

Block Cipher Padding

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public enum Padding

Members

Member name Description
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

See Also

CryptoSysAPI Namespace

PrfAlgorithm Enumeration

Pseudorandom function (PRF) algorithm.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public enum PrfAlgorithm

Members

Member name Description
Kmac128 KMAC128 as per NIST SP 800-185
Kmac256 KMAC256 as per NIST SP 800-185

See Also

CryptoSysAPI Namespace

Rng.Options Enumeration

Rng options

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public enum Options

Members

Member name Description
Default Default option
NoIntelDrng Turn off support for INTEL(R) DRNG for the current session.

See Also

CryptoSysAPI Namespace

Rng.Strength Enumeration

Required security strength for user-prompted entropy

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public enum Strength

Members

Member name Description
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

See Also

CryptoSysAPI Namespace

Wipe.Options Enumeration

Wipe options.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public enum Options

Members

Member name Description
Default Default options (DOD 7-pass)
Dod7Pass DOD 7-pass (default)
Simple Overwrite with single pass of zero bytes (quicker but less secure).

See Also

CryptoSysAPI Namespace

XofAlgorithm Enumeration

Extendable-output function (XOF) algorithm.

Namespace: CryptoSysAPI
Assembly: diCrSysAPINet (in diCrSysAPINet.dll) Version: 6.22.2.36349 (6.22.2.0)

Syntax

public enum XofAlgorithm

Members

Member name Description
Shake128 SHAKE128 as per FIPS PUB 202
Shake256 SHAKE256 as per FIPS PUB 202
Ascon_Xof ASCON-XOF extendable output function
Ascon_XofA ASCON-XOFA extendable output function
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)

See Also

CryptoSysAPI Namespace


Created: 2025-10-20 20:12:37
Copyright (C) 2025 D.I. Management Services Pty Ltd t/a CryptoSys https://cryptosys.net