如何在javascript中加密/解密URL参数? [英] How to encrypt/decrypt URL parameters in javascript?

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

问题描述

在任何人跳入之前,哦,这是一个坏主意,我知道是这样的。



我想保持关键和价值查询字符串不容易被最终用户看到。
我有这样的东西google.com/?category=textile&user=user1
我需要让它无法理解像这样:google.com/?kasjdhfkashasdfsf32423



有没有办法在javascript中实现这一点。我已经看过这个



我已经看过这个
编码URL?
和这个
http://forums.asp.net/t/1772334.aspx



但我不认为编码会解决问题。此外,此代码完全在客户端。我知道这不安全,但我只是需要这是一个天真,弱的防守。
请帮助。



编辑:



如果我的问题以前不清楚,我们深表歉意。 / p>

正在从其他应用程序传递URLgoogle.com/?category=textile&user=user1。
在查询字符串中传递的值直接控制向用户显示的内容。同样,任何没有技术知识的人都可以轻松地改变价值并查看与其他类别或用户相对应的数据。我需要使这个不可理解的事情是不明显的。如果一个用户是一个技术人员,并计算出使用的加密,那就没关系。我需要一个暂停解决方案,直到我们有一个更好的架构。

解决方案

如果你不寻找严重的强密码,可以使用ROT13:



http:// en.wikipedia.org/wiki/ROT13



这对您的网址中的轻微模糊键/值足够了。


Before anyone jumps in and says, "Oh!! that's a bad idea", I know it is.

I want to keep both the key and value in the query string to be not easily visible to the end user. I have something like this google.com/?category=textile&user=user1 I need to make it unintelligible like this :google.com/?kasjdhfkashasdfsf32423

Is there any way to achieve this in javascript. I have already seen this

I have already seen this Encode URL in JavaScript? and this http://forums.asp.net/t/1772334.aspx.

but I don't think encoding will solve the problem. Also, this code is entirely in client side. I know that it is not secure but I just need this is a naive,weak defense. Please help.

Edit:

I apologize if my question was not clear earlier.

The URL "google.com/?category=textile&user=user1" is being passed on from a different application. The values passed in the query string directly controls what is being displayed to the user. As is, anyone with no technical knowledge can easily change the value and view the data corresponding to a different category or user. I need to make this unintelligible so that it is not obvious. If a user is a techie and figures out the encryption used, then it is fine. I need a stop-gap solution till we have a better architecture in place

解决方案

If you don't looking for serious strong crypto, you can use ROT13:

http://en.wikipedia.org/wiki/ROT13

This is enough for slightly obfuscate keys/values in the your URLs.

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

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