Skip to content

Instantly share code, notes, and snippets.

@JamoCA
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JamoCA/eeb92f8fed6764110553 to your computer and use it in GitHub Desktop.
Save JamoCA/eeb92f8fed6764110553 to your computer and use it in GitHub Desktop.
Sample Implementation of the ColdFusion hashids library http://www.hashids.org/coldfusion/
<cfscript>
/* Download and install the hashids CFC https://github.com/dswitzer/hashids.coldfusion */
hashids = new Hashids(salt="this is my salt"
,minLen=8
,alphabet="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890");
id_to_hash = listtoArray("1"); // try "1,2,3" and "3,2,1" and "1,1,1"
writeoutput('original = #arrayToList(id_to_hash)#<br>');
hashed_id = hashids.encrypt(id_to_hash);
writeoutput('hash = #hashed_id#<br>');
unhashed_id = arraytolist(hashids.decrypt(hashed_id));
writeoutput('unhashed = #unhashed_id#<br>');
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment