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
databyte[]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
textstringThe 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
textstringThe string to convert to encryption data.
encodingEncodingThe encoding to use for conversion.
Fields
DefaultEncoding
Determines the default text encoding across ALL DataCrypt instances.
public static Encoding DefaultEncoding
Field Value
Encoding
Determines the default text encoding for this DataCrypt instance.
public Encoding Encoding
Field Value
Properties
Base64
Sets or returns Base64 string representation of this data.
public string Base64 { get; set; }
Property Value
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
IsEmpty
Returns true if no data is present.
public bool IsEmpty { get; }
Property Value
MaxBits
Maximum number of bits allowed for this data; if 0, no limit.
public int MaxBits { get; set; }
Property Value
MaxBytes
Maximum number of bytes allowed for this data; if 0, no limit.
public int MaxBytes { get; set; }
Property Value
MinBits
Minimum number of bits allowed for this data; if 0, no limit.
public int MinBits { get; set; }
Property Value
MinBytes
Minimum number of bytes allowed for this data; if 0, no limit.
public int MinBytes { get; set; }
Property Value
StepBits
Allowed step interval, in bits, for this data; if 0, no limit.
public int StepBits { get; set; }
Property Value
StepBytes
Allowed step interval, in bytes, for this data; if 0, no limit.
public int StepBytes { get; set; }
Property Value
Text
Sets or returns text representation of bytes using the default text encoding.
public string Text { get; set; }
Property Value
Methods
FromFile(string)
Creates a new DataCrypt instance from the contents of a file.
public static Task<DataCrypt> FromFile(string filePath)
Parameters
filePathstringThe path to the file to read.
Returns
ToBase64()
Returns Base64 string representation of this data.
public string ToBase64()
Returns
ToHex()
Returns Hex string representation of this data.
public string ToHex()
Returns
ToString()
Returns text representation of bytes using the default text encoding.
public string ToString()