开发者

Encryption Algorithm without special characters

Is the开发者_JS百科re an encryption algorithm in ColdFusion that doesn't use any special characters (only alphanumeric)? I have some data that I am passing to a user as a pseudo password which includes their username and the site that they are assigned to. I need to encrypt the string with an encryption algorithm built into ColdFusion 8 Enterprise edition and it cannot have any special characters in the final string. Is this possible and if so what algorithm will do this?

<cfset loc.token = encrypt(loc.token,Application.secretKey,'Blowfish','Base64') />


Just use binhex. Encode each byte as a hexadecimal number, ranging from 00 to FF. Base 64, however, includes several nonalphanumeric characters, such as + / = .


This should work for you,

#encrypt('text_im_encrypting', ToBase64(BinaryDecode('my_encrypt_key',"Hex")), 'AES', 'Hex');#

replace the *text_im_encrypting* and *my_encrypt_key* values obviously... =)


There are two undocumented functions, cfusion_encrypt(string, key) and cfusion_decrypt(string, key), that encrypt/decrypt based on hexadecimal strings. So essentially, since the resulting string is completely hex, it contains no special characters:

<cfscript>
    writeoutput(cfusion_encrypt("stackoverflow", "rocks")); // outputs 011B0208181D190619151E0014
    writeoutput(cfusion_decrypt("011B0208181D190619151E0014", "rocks")); // outputs stackoverflow
</cfscript>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜