[英]decrypt data in view in MVC?
public static string setEncrypt_Account(string sParam)
{
sParam = Core_App.RijndaelSimple.Encrypt(sParam, "pr@se_AccPwd", "cts@devteam", "MD5", 2, "@1B2c3D4e5F6g7H8", 256);
return sParam;
}
public static string getDecrypt_Account(string sParam)
{
sParam = Core_App.RijndaelSimple.Decrypt(sParam, "pr@se_AccPwd", "cts@devteam", "MD5", 2, "@1B2c3D4e5F6g7H8", 256);
return sParam;
}
您應該在edit(get)操作上調用getDecrypt_Account(string sParam)
來解密數據,然后傳遞給視圖。 就像是:
@using Your.Decrypt.Method.Path;
[HttpGet]
public ActionResult Edit(int id)
{
User user = new Repository().GetUser(id);
return View(new EditViewModel()
{
Code = user.Code,
UserName = getDecrypt_Account(user.UserName),
FullName = user.FullName
});
}
我希望你明白這個主意。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.