/// <summary> /// Decrypts a cipher text using a specified symmetric cryptography provider. /// </summary> /// <param name="symmetricInstance">A symmetric instance from configuration.</param> /// <param name="ciphertextBase64">The cipher text as a base64 encoded string for which you want to decrypt.</param> /// <returns>The resulting plain text as a string.</returns> public override string DecryptSymmetric(string symmetricInstance, string ciphertextBase64) { ISymmetricCryptoProvider symmetricProvider = GetSymmetricCryptoProvider(symmetricInstance); return(Cryptographer.DecryptSymmetric(symmetricProvider, ciphertextBase64)); }
/// <summary> /// Compares plain text input with a computed hash using the given hash provider instance. /// </summary> /// <remarks> /// Use this method to compare hash values. Since hashes contain a random "salt" value, two seperately generated /// hashes of the same plain text will result in different values. /// </remarks> /// <param name="hashInstance">A hash instance from configuration.</param> /// <param name="plaintext">The input as a string for which you want to compare the hash to.</param> /// <param name="hashedText">The hash as a string for which you want to compare the input to.</param> /// <returns><c>true</c> if plainText hashed is equal to the hashedText. Otherwise, <c>false</c>.</returns> public override bool CompareHash(string hashInstance, string plaintext, string hashedText) { IHashProvider hashProvider = GetHashProvider(hashInstance); return(Cryptographer.CompareHash(hashProvider, plaintext, hashedText)); }
/// <summary> /// Encrypts a secret using a specified symmetric cryptography provider. /// </summary> /// <param name="symmetricInstance">A symmetric instance from configuration.</param> /// <param name="plaintext">The input as a base64 encoded string for which you want to encrypt.</param> /// <returns>The resulting cipher text as a base64 encoded string.</returns> public override string EncryptSymmetric(string symmetricInstance, string plaintext) { ISymmetricCryptoProvider symmetricProvider = GetSymmetricCryptoProvider(symmetricInstance); return(Cryptographer.EncryptSymmetric(symmetricProvider, plaintext)); }
/// <summary> /// Computes the hash value of plain text using the given hash provider instance /// </summary> /// <param name="hashInstance">A hash instance from configuration.</param> /// <param name="plaintext">The input for which to compute the hash.</param> /// <returns>The computed hash code.</returns> public override string CreateHash(string hashInstance, string plaintext) { IHashProvider hashProvider = GetHashProvider(hashInstance); return(Cryptographer.CreateHash(hashProvider, plaintext)); }