Class that provides a number of encryption utilities.
Westwind.Utilities.Encryption
public static class Encryption : object
Remarks
For best compatibility across platforms of the Encrypt/Decrypt methods use overloads that use the key as a byte[24] value rather than string or other sized buffers.
Class Members
Member | Description | |
---|---|---|
EncryptionKey |
Replace this value with some unique key of your own Best set this in your App start up in a Static constructor | |
EncryptionKeySize |
Global configuration propery that can be overridden to set the key size used for Encrypt/Decript operations. Choose between 16 bytes (not recommended except for backwards compatibility) or 24 bytes (works both in NET Full and NET Core) | |
BinaryToBinHex |
Converts a byte array into a BinHex string. Example: 01552233 where the numbers are packed byte values. public static string BinaryToBinHex(Byte[] data) |
|
BinHexToBinary |
Turns a BinHex string that contains raw byte values into a byte array public static Byte[] BinHexToBinary(string hex) |
|
ComputeHash |
Generates a hash for the given plain text value and returns a base64-encoded result. Before the hash is computed, a random salt is generated and appended to the plain text. This salt is stored at the end of the hash value, so it can be used later for hash verification. public static string ComputeHash(string plainText, string hashAlgorithm, Byte[] saltBytes, bool useBinHex) public static string ComputeHash(string plainText, string hashAlgorithm, string salt, bool useBinHex) public static string ComputeHash(Byte[] byteData, string hashAlgorithm, Byte[] saltBytes, bool useBinHex) |
|
DecryptBytes |
Decrypts a Byte array from DES with an Encryption Key. public static Byte[] DecryptBytes(Byte[] decryptBuffer, string encryptionKey) public static Byte[] DecryptBytes(Byte[] decryptBuffer, SecureString encryptionKey) public static Byte[] DecryptBytes(Byte[] decryptBuffer, Byte[] encryptionKey, CipherMode cipherMode) public static Byte[] DecryptBytes(string decryptString, string encryptionKey, bool useBinHex) public static Byte[] DecryptBytes(string decryptString, SecureString encryptionKey, bool useBinHex) |
|
DecryptString |
Decrypts a string using DES encryption and a pass key that was used for encryption. public static string DecryptString(string decryptString, string encryptionKey, bool useBinHex) public static string DecryptString(string decryptString, SecureString encryptionKey, bool useBinHex) public static string DecryptString(string decryptString, Byte[] encryptionKey, bool useBinHex) |
|
EncryptBytes |
Encodes a stream of bytes using DES encryption with a pass key. Lowest level method that handles all work. public static Byte[] EncryptBytes(Byte[] inputBytes, string encryptionKey) public static Byte[] EncryptBytes(Byte[] inputBytes, SecureString encryptionKey) public static Byte[] EncryptBytes(Byte[] inputBytes, Byte[] encryptionKey, CipherMode cipherMode) public static Byte[] EncryptBytes(string inputString, string encryptionKey) |
|
EncryptString |
Encrypts a string using Triple DES encryption with a two way encryption key.String is returned as Base64 or BinHex encoded value rather than binary. public static string EncryptString(string inputString, Byte[] encryptionKey, bool useBinHex) public static string EncryptString(string inputString, string encryptionKey, bool useBinHex) public static string EncryptString(string inputString, SecureString encryptionKey, bool useBinHex) |
|
GetChecksumFromBytes |
Create a SHA256 or MD5 checksum from a bunch of bytes public static string GetChecksumFromBytes(Byte[] fileData, string mode) |
|
GetChecksumFromFile |
Creates an SHA256 or MD5 checksum of a file public static string GetChecksumFromFile(string file, string mode) |
|
GZipFile |
Encodes one file to another file that is gzip compressed. File is overwritten if it exists and not locked. public static bool GZipFile(string Filename, string OutputFile) |
|
GZipMemory |
GZip encodes a memory buffer to a compressed memory buffer public static Byte[] GZipMemory(Byte[] buffer) public static Byte[] GZipMemory(string Input) public static Byte[] GZipMemory(string Filename, bool IsFile) |
Requirements
Namespace: Westwind.UtilitiesAssembly: westwind.utilities.dll
© West Wind Technologies, 1996-2024 • Updated: 06/29/24
Comment or report problem with topic