Cryptographer
Facade which exposes common cryptography uses.
- Namespace:
- Inetdev.Security.Cryptography
- Type:
- Class
- Public:
- Yes
- Protected:
- No
- Sealed:
- Yes
- Abstract:
- Yes
- Inherits from:
- System.Object
Properties
Configuration
Provides access to configuration.
- Signature:
public IConfiguration Configuration { get; set; }
Methods
CompareHash
Compares a plain text input with a computed hash.
- Signature:
public Boolean CompareHash(plaintext, hashedtext)
Returns
true if the hash matches, otherwhise false.
Parameters
Name |
Type |
Summary |
plaintext |
Byte[] |
The input to compare with the hash. |
hashedtext |
Byte[] |
The hash value to compare the input value. to |
CompareHash
Compares a plain text input with a computed hash.
- Signature:
public Boolean CompareHash(provider, plaintext, hashedtext)
Returns
true if the hash matches, otherwhise false.
Parameters
Name |
Type |
Summary |
provider |
IHashProvider |
The HashProvider used to compare. |
plaintext |
Byte[] |
The input to compare with the hash. |
hashedtext |
Byte[] |
The hash value to compare with the input value. |
Exceptions
Type |
Summary |
ArgumentNullException |
Thrown when provider is null. |
CompareHash
Compares a plain text input with a computed hash.
- Signature:
public Boolean CompareHash(provider, plaintext, hashedtext)
Returns
true if the hash matches, otherwhise false.
Parameters
Name |
Type |
Summary |
provider |
IHashProvider |
The HashProvider used to compare. |
plaintext |
String |
The input to compare with the hash. |
hashedtext |
String |
The hash value to compare with the input value. |
Exceptions
Type |
Summary |
ArgumentNullException |
Thrown when provider is null. |
CompareHash
Compares a plain text input with a computed hash.
- Signature:
public Boolean CompareHash(plaintext, hashedtext)
Returns
true if the hash matches, otherwhise false.
Parameters
Name |
Type |
Summary |
plaintext |
String |
The input to compare with the hash. |
hashedtext |
String |
The hash value to compare with the input value. |
ComputeHash
Compute the hash value of plain text.
- Signature:
public Byte[] ComputeHash(plaintext)
Returns
The computed hash value.
Parameters
Name |
Type |
Summary |
plaintext |
Byte[] |
The input to compute the hash for. |
ComputeHash
Compute the hash value of plain text.
- Signature:
public Byte[] ComputeHash(provider, plaintext)
Returns
The computed hash value.
Parameters
Name |
Type |
Summary |
provider |
IHashProvider |
The HashProvider used to compute the hash. |
plaintext |
Byte[] |
The input to compute the hash for. |
Exceptions
Type |
Summary |
ArgumentNullException |
Thrown when provider is null. |
ComputeHash
Computes the hash for the specified stream.
- Signature:
public Byte[] ComputeHash(provider, stream)
Returns
A hash code for the specified stream.
Parameters
Exceptions
Type |
Summary |
ArgumentNullException |
Thrown when provider is null. |
ComputeHash
Compute the hash value of plain text.
- Signature:
public Byte[] ComputeHash(provider, plaintext)
Returns
The computed hash value.
Parameters
Name |
Type |
Summary |
provider |
IHashProvider |
The HashProvider used to compute the hash. |
plaintext |
String |
The input to compute the hash for. |
Exceptions
Type |
Summary |
ArgumentNullException |
Thrown when provider is null. |
ComputeHash
Computes the hash for the specified stream.
- Signature:
public Byte[] ComputeHash(stream)
Returns
The computed hash value.
Parameters
Name |
Type |
Summary |
stream |
Stream |
A Stream to compute it's hash. |
ComputeHash
Computes the hash value of plain text.
- Signature:
public Byte[] ComputeHash(plaintext)
Returns
The computed hash value.
Parameters
Name |
Type |
Summary |
plaintext |
String |
The input to compute the hash for. |
Decrypt
Decrypts a ciphered text using a SymmetricAlgorithm.
- Signature:
public Byte[] Decrypt(ciphertext)
Parameters
Name |
Type |
Summary |
ciphertext |
Byte[] |
The cipher text to decrypt. |
Exceptions
Decrypt
Decrypts a ciphered text using a specified ISymmetricProvider.
- Signature:
public Byte[] Decrypt(provider, ciphertext)
Parameters
Name |
Type |
Summary |
provider |
ISymmetricProvider |
The symetric provider to use. |
ciphertext |
Byte[] |
The cipher text to decrypt. |
Exceptions
Decrypt
Decrypts a ciphered stream using the specified ISymmetricProvider.
- Signature:
public Void Decrypt(provider, source, destination)
Parameters
Name |
Type |
Summary |
provider |
ISymmetricProvider |
The symmetric provider. |
source |
Stream |
The source stream to decrypt. |
destination |
Stream |
The destination stream where the plain text result should be written. |
Exceptions
Type |
Summary |
CryptographyException |
Thrown when an error occurs while transforming the data. |
ArgumentNullException |
Thrown when provider is null. |
ArgumentNullException |
Thrown when source or destination are null. |
Decrypt
Decrypts a ciphered text using a specified ISymmetricProvider.
- Signature:
public Byte[] Decrypt(provider, ciphertext)
Parameters
Name |
Type |
Summary |
provider |
ISymmetricProvider |
The symmetric provider. |
ciphertext |
String |
The cipher text to decrypt. |
Exceptions
Decrypt
Decrypts a ciphered stream using a SymmetricAlgorithm.
- Signature:
public Void Decrypt(source, destination)
Parameters
Name |
Type |
Summary |
source |
Stream |
The source stream to decrypt. |
destination |
Stream |
The destination stream where the plain text result should be written. |
Exceptions
Type |
Summary |
CryptographyException |
Thrown when an error occurs while transforming the data. |
ArgumentNullException |
Thrown when source or destination are null. |
Decrypt
Decrypts a ciphered text using a SymmetricAlgorithm.
- Signature:
public Byte[] Decrypt(ciphertext)
Parameters
Name |
Type |
Summary |
ciphertext |
String |
The cipher text to decrypt. |
Exceptions
DecryptFromBase64String
Decrypts a base 64 encoded ciphered text.
- Signature:
public String DecryptFromBase64String(cipheredtext)
Remarks
If cipheredtext is null or empty, null is returned.
Parameters
Name |
Type |
Summary |
cipheredtext |
String |
Ciphered text to be decrypted. |
Exceptions
Encrypt
Encrypts a secret using a SymmetricAlgorithm.
- Signature:
public Byte[] Encrypt(plaintext)
Parameters
Name |
Type |
Summary |
plaintext |
Byte[] |
The input to encrypt. |
Exceptions
Encrypt
Encrypts a secret using a specified IServiceProvider.
- Signature:
public Byte[] Encrypt(provider, plaintext)
Parameters
Name |
Type |
Summary |
provider |
ISymmetricProvider |
The symmetric provider. |
plaintext |
Byte[] |
The input to encrypt. |
Exceptions
Encrypt
Encrypts the secret in source into destination
using the specified ISymmetricProvider.
- Signature:
public Void Encrypt(provider, source, destination)
Parameters
Name |
Type |
Summary |
provider |
ISymmetricProvider |
The symmetric provider. |
source |
Stream |
The source stream to encrypt. |
destination |
Stream |
The destination stream where the ciphered text should be written. |
Exceptions
Type |
Summary |
CryptographyException |
Thrown when an error occurs while transforming the data. |
ArgumentNullException |
Thrown when provider is null. |
ArgumentNullException |
Thrown when source or destination are null. |
Encrypt
Encrypts a secret using a specified ISymmetricProvider.
- Signature:
public Byte[] Encrypt(provider, plaintext)
Parameters
Name |
Type |
Summary |
provider |
ISymmetricProvider |
The symmetric provider. |
plaintext |
String |
The input to encrypt. |
Exceptions
Encrypt
Encrypts the secret in source into destination
using a SymmetricAlgorithm.
- Signature:
public Void Encrypt(source, destination)
Parameters
Name |
Type |
Summary |
source |
Stream |
The source stream to encrypt. |
destination |
Stream |
The destination stream where the cipher text should be written. |
Exceptions
Type |
Summary |
CryptographyException |
Thrown when an error occurs while transforming the data. |
ArgumentNullException |
Thrown when source or destination are null. |
Encrypt
Encrypts a secret using a SymmetricAlgorithm.
- Signature:
public Byte[] Encrypt(plaintext)
Parameters
Name |
Type |
Summary |
plaintext |
String |
A secret to be encrypted. |
Exceptions
EncryptToBase64String
Encrypts a secret and returns the encryption as a Base 64 string.
- Signature:
public String EncryptToBase64String(plaintext)
Remarks
If plaintext is null or empty, null is returned.
Parameters
Name |
Type |
Summary |
plaintext |
String |
A secret to be encrypted. |
Exceptions