How to encrypt and decrypt data in MVC?

后端 未结 2 1965
日久生厌
日久生厌 2021-01-26 13:19

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

2条回答
  •  情话喂你
    2021-01-26 14:08

    based on this comment: "suppose i am sending an id from my view to my controller and i want to encrypt this 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.

    In this case, you can encrypt the "id" after put it on the client, and then the controller decrypt only the "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:

    https://stackoverflow.com/a/14774470/138071
    http://amitpatelit.com/2011/08/08/url-encryption-in-mvc-application/

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

    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

提交回复
热议问题