Request.Querystring 从加密文本中删除字符

发布于 2024-08-11 05:53:54 字数 788 浏览 3 评论 0原文

在我的应用程序中,我获取用户的电子邮件地址,对其进行加密、URLEncode,然后将其传递到查询字符串中。

email = Server.UrlEncode(aes.Encrypt(email));

登陆页面执行 Request.Querystring["email"]、UrlDecodes,然后解密。

    string email            = Server.UrlDecode(Request.QueryString["eId"]);
    string decemail         = aes.Decrypt(email);
    return decemail;

当“+”字符被删除时,发生了非常奇怪的行为,因此解密失败。

我尝试删除 UrlDecode,但这并没有解决问题。

解决问题的方法是这样做:

        string email            = Request.QueryString["eId"].ToString();
        string decemail         = aes.Decrypt(email);
        return decemail;

摆脱 UrlDecode,并在查询字符串上调用 ToString()。

有谁知道为什么会发生这种情况? Request.QueryString默认调用urlDecode吗?我认为不会。

另外,为什么在这种情况下执行 .ToString() 会起作用?

In my application I take a user's e-mail address, encrypt it, and URLEncode it, and pass it along into a QueryString.

email = Server.UrlEncode(aes.Encrypt(email));

The landing page does a Request.Querystring["email"], UrlDecodes it, and then decrypts it.

    string email            = Server.UrlDecode(Request.QueryString["eId"]);
    string decemail         = aes.Decrypt(email);
    return decemail;

Very strange behavior was happening where a "+" character was being removed and therefore the decryption was failing.

I attempted to remove the UrlDecode, but that didn't solve the problem.

What solved the problem was doing this:

        string email            = Request.QueryString["eId"].ToString();
        string decemail         = aes.Decrypt(email);
        return decemail;

Getting rid of UrlDecode, and calling a ToString() on the querystring.

Does anyone know why this would happen? Does Request.QueryString call urlDecode by default? I don't think it does.

Also, why would doing the .ToString() work in this instance?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只怪假的太真实 2024-08-18 05:53:54

是的,正确。 Request.QueryString实际上返回已经被url解码的字符串。

资料来源:

http://www.codeproject.com/KB /custom-controls/antiauto.aspx?msg=1475521

http://www.kamath.com/codelibrary/cl006_url.asp

Yep Correct. Request.QueryString actually returns string that has already been url decoded.

Sources:

http://www.codeproject.com/KB/custom-controls/antiauto.aspx?msg=1475521

http://www.kamath.com/codelibrary/cl006_url.asp

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文