我有以下脚本尝试从我的数据库中选择一些项目并解密加密的项目,问题是加密密钥是唯一的,我在表格中更改了company_id
:
<cfset request.ek = "password">
<!-- <cfset encKey = encrypt(request.ek, company_id)> -->
<!-- <cfset decrypted = decrypt(urldecode(arguments.mystring), encKey)> -->
<cfquery name="header" datasource="MyDB">
SELECT TOP 10
ID,
company_id,
encString
FROM
dbo.[TableName];
</cfquery>
<cfoutput>ID|company_id|encString<br></cfoutput>
<cfloop query="header">
<cfoutput>#ID#|#company_id#|#decrypt(urldecode(encString, encrypt(request.eq, company_id)))#<br></cfoutput>
</cfloop>
我收到此错误:
Parameter validation error for the DECRYPT function.
The function accepts 2 to 6 parameters.
EDIT。 谢谢Scott Stroz,我真的和括号混在一起。我的代码应该是:
<cfset request.ek = "password">
<!-- <cfset encKey = encrypt(request.ek, company_id)> -->
<!-- <cfset decrypted = decrypt(urldecode(arguments.mystring), encKey)> -->
<cfquery name="header" datasource="MyDB">
SELECT TOP 10
ID,
company_id,
encString
FROM
dbo.[TableName];
</cfquery>
<cfoutput>ID|company_id|encString<br></cfoutput>
<cfloop query="header">
<cfoutput>#ID#|#company_id#|#decrypt(urldecode(encString), encrypt(request.eq, company_id))#<br></cfoutput>
</cfloop>
答案 0 :(得分:3)
您在代码示例末尾附近对decrypt()的调用只有1个参数。看起来你的括号可能有问题。
看起来像:
decrypt(urldecode(encString, encrypt(request.eq, company_id)))
可能需要:
decrypt(urldecode(encString), encrypt(request.eq, company_id))
假设
request.eq
加密了字符串,密钥为company_id
。