Table of Contents

Class DataCrypt

Namespace
SunamoShared.Crypting
Assembly
SunamoShared.dll

Represents Hex, Byte, Base64, or String data to encrypt/decrypt. Use the .Text property to set/get a string representation. Use the .Hex property to set/get a string-based Hexadecimal representation. Use the .Base64 to set/get a string-based Base64 representation. Used in classes Asymmetric, Symmetric, Hash.

public class DataCrypt
Inheritance
DataCrypt
Inherited Members
Extension Methods

Constructors

DataCrypt()

Initializes a new empty instance of the DataCrypt class.

public DataCrypt()

DataCrypt(byte[])

Initializes a new instance of the DataCrypt class from a byte array.

public DataCrypt(byte[] data)

Parameters

data byte[]

The byte array data.

DataCrypt(string)

Creates new encryption data with the specified string; will be converted to byte array using default encoding.

public DataCrypt(string text)

Parameters

text string

The string to convert to encryption data.

DataCrypt(string, Encoding)

Creates new encryption data using the specified string and encoding to convert the string to a byte array.

public DataCrypt(string text, Encoding encoding)

Parameters

text string

The string to convert to encryption data.

encoding Encoding

The encoding to use for conversion.

Fields

DefaultEncoding

Determines the default text encoding across ALL DataCrypt instances.

public static Encoding DefaultEncoding

Field Value

Encoding

Encoding

Determines the default text encoding for this DataCrypt instance.

public Encoding Encoding

Field Value

Encoding

Properties

Base64

Sets or returns Base64 string representation of this data.

public string Base64 { get; set; }

Property Value

string

Bytes

Returns the byte representation of the data. This will be padded to MinBytes and trimmed to MaxBytes as necessary.

public byte[] Bytes { get; set; }

Property Value

byte[]

Hex

Sets or returns Hex string representation of this data.

public string Hex { get; set; }

Property Value

string

IsEmpty

Returns true if no data is present.

public bool IsEmpty { get; }

Property Value

bool

MaxBits

Maximum number of bits allowed for this data; if 0, no limit.

public int MaxBits { get; set; }

Property Value

int

MaxBytes

Maximum number of bytes allowed for this data; if 0, no limit.

public int MaxBytes { get; set; }

Property Value

int

MinBits

Minimum number of bits allowed for this data; if 0, no limit.

public int MinBits { get; set; }

Property Value

int

MinBytes

Minimum number of bytes allowed for this data; if 0, no limit.

public int MinBytes { get; set; }

Property Value

int

StepBits

Allowed step interval, in bits, for this data; if 0, no limit.

public int StepBits { get; set; }

Property Value

int

StepBytes

Allowed step interval, in bytes, for this data; if 0, no limit.

public int StepBytes { get; set; }

Property Value

int

Text

Sets or returns text representation of bytes using the default text encoding.

public string Text { get; set; }

Property Value

string

Methods

FromFile(string)

Creates a new DataCrypt instance from the contents of a file.

public static Task<DataCrypt> FromFile(string filePath)

Parameters

filePath string

The path to the file to read.

Returns

Task<DataCrypt>

ToBase64()

Returns Base64 string representation of this data.

public string ToBase64()

Returns

string

ToHex()

Returns Hex string representation of this data.

public string ToHex()

Returns

string

ToString()

Returns text representation of bytes using the default text encoding.

public string ToString()

Returns

string