Skip to content

Instantly share code, notes, and snippets.

@configureappio
Created April 2, 2018 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save configureappio/efc0bc4b4db24b749c4424c90f33078f to your computer and use it in GitHub Desktop.
Save configureappio/efc0bc4b4db24b749c4424c90f33078f to your computer and use it in GitHub Desktop.
Example of decrypting a dictionary with a hashed key
public class SettingsDecryptor : ISettingsDecrypt
{
private readonly ICryptoAlgorithm _crypto;
public SettingsDecryptor(ICryptoAlgorithm crypto)
{
_crypto = crypto ?? throw new ArgumentNullException(nameof(crypto));
}
public string Decrypt(string key, IDictionary<string, string> keyValues)
{
var hashedKey = _crypto.HashKey(key);
var value = keyValues[hashedKey];
return DecryptValue(value);
}
private string DecryptValue(string encodedString)
{
return _crypto.Decrypt(encodedString);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment