title: What is the best way to show an encrypted database value in a view?
body: <p>I am encrypting 2 properties on a model when they are saved to the database with the Data Protection APIs in ASP.NET Core. </p>
  
  <p>I'm currently decrypting it before showing it in the view but this can't be the right way to handle a scenario like this?</p>
  
  <pre><code>   //GET: admin/editBankaccount
      public async Task&lt;IActionResult&gt; EditBankAccount(string id)
      {
          var bankAccount = await _context.GetBankAccountAsync(id);
  
          //decrypt bankaccount no. and reg.
  
          var bankNo = _protector.Unprotect(bankAccount.AccountNo);
          var regNo = _protector.Unprotect(bankAccount.AccountReg);    
          bankAccount.AccountNo = bankNo;
          bankAccount.AccountReg = regNo;
  
          return View(bankAccount);
      }
  </code></pre>
  
  <p>There must be a simpler way to do this?</p>