如何加密和MVC中解密数据? [英] How to encrypt and decrypt data in MVC?

查看:331
本文介绍了如何加密和MVC中解密数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 MVC应用程序我要的加密解密从视图控制器的数据传输的数据。如何做到这一点的 MVC 4 使用的剃须刀

In my MVC application i want to encrypt and decrypt data in data transmission from view to Controller . How to do this in MVC 4 using Razor ?

推荐答案

根据此评论: ?假如我是从我的观点给我的控制器发送一个ID,我想加密此ID

based on this comment: "suppose i am sending an id from my view to my controller and i want to encrypt this id ?"

如果你想在一个视图加密ID,在这种情况下,你已经在视图中的ID,ID会在数据库或其他,但不是在客户端生成。

if you want to encrypt the "id" in a view, in this case you already have the "id" in the view, "id" would be generated in the database or other but not in the client.

在这种情况下,您可以加密的ID把它在客户端上后,再用控制器仅解密的身份证。

In this case, you can encrypt the "id" after put it on the client, and then the controller decrypt only the "id".

在这里,您有一个仅加密ID,这是出于安全完成,这样的数据是不是找ID的例子。

Here you have an example that encrypts only the "id", this is done for security so that data is not looking for "id".

在这种情况下,你必须进行加密和解密的属性:

In this case you have to encrypt and decrypt the property:

http://stackoverflow.com/a/14774470/138071

http://amitpatelit.com/2011/08/08/ URL加密功能于MVC应用程序/

在这个例子中(西班牙文)确实为那些用下划线收到的所有参数(_):

In this example (in Spanish) does for all parameters that are received with an underscore (_):

<一个href=\"http://geeks.ms/blogs/etomas/archive/2012/07/08/asp-net-mvc-encriptar-routevalues.aspx?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3a%20BurbujasNetGeeks%20%28Burbujas%20en%20.NET%20%28@geeks.ms%29%29\" rel=\"nofollow\">http://geeks.ms/blogs/etomas/archive/2012/07/08/asp-net-mvc-encriptar-routevalues.aspx?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+BurbujasNetGeeks+%28Burbujas+en+.NET+%28%40geeks.ms%29%29

这篇关于如何加密和MVC中解密数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆