在ColdFusion中隐藏/加密URL变量 [英] Hide/Encrypt URL variables in ColdFusion

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

问题描述

如果我有一个网站,且网址为 www.example.com/mainpage.cfm?id=0123&app=2 ,我如何隐藏 id = 0123 app = 2 ,因此用户将无法更改这些变量?



我在看一个由我之前的人写的复杂程序,他通过URL将这些变量从一个页面传递到另一个页面。我只是寻找一个快速修复,因为我不想重写整个程序。

解决方案

it:

  #URLEncodedFormat(Encrypt(id,#key#))#

id是变量,密钥可以是任何(用作证书进行编码和解码)。



要解码:

  cfset url.id = #Decrypt(url.id,#key #)#

同样,关键变量也是与要编码的变量相同的变量。 p>

If I have a website and the URL is www.example.com/mainpage.cfm?id=0123&app=2, how can I hide the id=0123 and app=2 so the user won't be able to change these variables?

I am looking at a complex program written by someone before me and he is passing these variables from page to page through the URL. I am just looking for a quick fix because I don't want to rewrite this entire program.

解决方案

Here is how you encode it:

#URLEncodedFormat(Encrypt(id, "#key#"))#

The id is the variable, and the key can be anything (used as a certificate to encode and decode).

To Decode:

cfset url.id = #Decrypt(url.id, "#key#")#

Again the key variable would be the same variable as the one to encode.

这篇关于在ColdFusion中隐藏/加密URL变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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