简体   繁体   English

使用JavaScript解密数据-ASP.NET网站

[英]Decrypting data with javascript - ASP.NET website

I use a hidden variable (input type=hidden) to store ID information on a page. 我使用一个隐藏变量(输入类型=隐藏)将ID信息存储在页面上。 To prevent attackers, I decided to encrypt the data stored using System.Security.Cryptography . 为了防止攻击者,我决定使用System.Security.Cryptography加密存储的数据。

The hidden variable is accessed in JS and executes validation logic. 隐藏变量在JS中访问并执行验证逻辑。 I will need to decrypt the data before executing the validation logic. 在执行验证逻辑之前,我将需要解密数据。 Is there a way to decrypt data in JS that was encrypted using System.Security.Cryptography 有没有办法解密使用System.Security.Cryptography加密的JS中的数据

If you can decrypt it using JavaScript on the client side, so can any attacker. 如果您可以在客户端使用JavaScript对其解密,那么任何攻击者也可以。 This approach is flawed for that reason. 因此,这种方法存在缺陷。 The Validation logic also needs to be done server side. 验证逻辑也需要在服务器端完成。 You should never trust client side validation for anything that could potentially hurt your site. 对于任何可能损害您网站的内容,您永远不要相信客户端验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM