Class Crypto
- Namespace
- Dynamicweb.Security.SystemTools
- Assembly
- Dynamicweb.Core.dll
This class contains functions uses to Encrypt/Decrypt source.
public class Crypto : IDisposable
- Inheritance
-
Crypto
- Implements
- Inherited Members
Remarks
Crypto is a wrapper of System.Security.Cryptography.SymmetricAlgorithm classes and simplifies the interface. It supports customized SymmetricAlgorithm as well.
Constructors
Crypto(SymmProvEnum)
Determines kind of CryptoServiceProvider algorithm.
public Crypto(SymmProvEnum netSelected)
Parameters
netSelectedSymmProvEnumEnum of kinds.
Remarks
Constructor for using an intrinsic .Net SymmetricAlgorithm class.
Crypto(SymmetricAlgorithm)
Determines custom CryptoServiceProvider algorithm.
public Crypto(SymmetricAlgorithm serviceProvider)
Parameters
serviceProviderSymmetricAlgorithm
Remarks
Constructor for using a customized SymmetricAlgorithm class.
Fields
CryptoKey
public const string CryptoKey = "s5M1f3s8"
Field Value
disposed
protected bool disposed
Field Value
Methods
Decrypt(string)
Decrypts the specified value.For new scenarios use AES
public static string Decrypt(string value)
Parameters
valuestringThe value.
Returns
Decrypt(string, string)
Decrypts an input source using current Key parameter.
public string Decrypt(string source, string key)
Parameters
Returns
- string
String representation of the decrypted source.
DecryptAes(string)
Decrypts the specified value with AES.
public static string DecryptAes(string value)
Parameters
valuestringThe value.
Returns
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
protected virtual void Dispose(bool disposing)
Parameters
disposingbool
Encrypt(string)
Encrypts the specified value. For new scenarios use AES
public static string Encrypt(string value)
Parameters
valuestringThe value.
Returns
Encrypt(string, string)
Encrypts an input source using current Key parameter.
public string Encrypt(string source, string key)
Parameters
Returns
- string
Encrypted source converted into Base64 so that the result can be used in xml.
EncryptAes(string)
Encrypts the specified value with AES.
public static string EncryptAes(string value)
Parameters
valuestringThe value.
Returns
EncryptPassword(string, UserPasswordHashAlgorithm)
Encrypts a string with either MD5 or SHA512 encryption according to global settings.
public static string EncryptPassword(string password, UserPasswordHashAlgorithm hashAlgorithm)
Parameters
passwordstringThe password.
hashAlgorithmUserPasswordHashAlgorithmThe hash algorithm - either SHA512 or MD5 (default).
Returns
- string
The
passwordhashed with MD5 (default) or SHA512
Remarks
A string hashed with MD5 (default) or SHA512 cannot be reversed to plain text.
EncryptSha512(string, string)
Encrypts the specified value using the salt with SHA512.
public static string EncryptSha512(string value, string salt)
Parameters
Returns
- string
The hashed
value.
HexToString(string)
Converts hex values to string.
public static string HexToString(string hex)
Parameters
hexstringThe hex.
Returns
StringToHex(string)
Converts strings to hex.
public static string StringToHex(string text)
Parameters
textstringThe text.