Skip to content

Instantly share code, notes, and snippets.

@hidegh
Last active July 22, 2016 05:59
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 hidegh/7a2ae10ce74d8222bb234b405c1aa0a3 to your computer and use it in GitHub Desktop.
Save hidegh/7a2ae10ce74d8222bb234b405c1aa0a3 to your computer and use it in GitHub Desktop.
public class BankingDetails
{
protected string EncryptedAccountNumber { get; set; }
protected string EncryptedRoutingTransitNumber { get; set; }
public string GetAccountNumber (IDecryptor decryptor)
{
return string.IsNullOrWhitespace(EncryptedAccountNumber) ? "" : decryptor.Decrypt(EncryptedAccountNumber);
}
public void SetAccountNumber (IEncryptor encryptor, string accountNumber)
{
// TODO: add input checking (format, etc.)
EncryptedAccountNumber = string.IsNullOrWhitespace(accountNumber) ? "" : encryptor.Encrypt(accountNumber);
}
// NOTE:
// ... so on for routing transit number
//
// BankingDetails class is an ORM mapped entity,
// ...and since I did not wanted to include service locator and had no better idea to inject IDecryptor and IEncryptor,
// ...had to use Get/Set methods (with additional IDecryptor/IEncryptor parameters) instead of plain getters/setters...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment