问题描述
堆栈溢出用户,
我有一个服务器端JQuery Datatable,并且正在尝试加密记录ID.我已经在CFLOOP中的基本数据表上使用了此方法,但是我无法在JavaScript中做到这一点.
I have a server side JQuery Datatable and I am attempting to encrypt the record ID. I've used this method on basic data tables in a CFLOOP but I have not been able to do it in JavaScript.
下面是我当前的代码.
{
"targets": 1,
"data": "LAST_NAME",
<cfset L = "'+ data+'"/>
<cfset l_id = Encrypt(L,myKey,'AES/CBC/PKCS5Padding','HEX') />
"render": function ( data, type, row, meta )
{return '<a href="candidate/?svr=#l_id#">'+ data+'</a>';},
},
当我解密该URL时,它显示 + data + .当我将其更改为使用 L 号码时,我会获得正确的ID号,但未加密
When I decrypt the url, it displays + data+. When I change it to use the L vairble, then I get the correct ID number but it is not encrypted
{return '<a href="candidate/?svr=#L#">'+ data+'</a>';}
我知道使用CFSCRIPT与它有关,但是我不清楚如何使用它.任何帮助都会很棒.
I know it has something to do with using CFSCRIPT yet I am unclear how to use this. Any help would be great.
推荐答案
尽管有很多用于加密url的方法,但我发现最好的方法是在JavaScript之前先拦截JSON请求中的EMPLOYEE_ID关闭.
Although, there are many methods for encrypting the url, I found in my case the best method was to intercept the EMPLOYEE_ID in the JSON request prior to the JavaScript hand off.
<cfset ED_ID = Encrypt(EMPLOYEE_ID,myKey,'AES/CBC/PKCS5Padding','HEX')/>
<cfset obj = {
"EMPLOYEE_ID" = variables.ED_ID,
从上面的示例中可以看到,在将Employee_ID传递给JSON响应之前已对其进行了修改.成功加密雇员ID并创建更安全的URL.
As you can see from the above example, the Employee_ID is modified before passing it to the JSON response. The successfully encrypts the employee id and creates the more secure URL.
这篇关于加密URL Coldfusion和JQuery数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!