Skip to content

Instantly share code, notes, and snippets.

@virtix
Created June 24, 2009 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save virtix/135153 to your computer and use it in GitHub Desktop.
Save virtix/135153 to your computer and use it in GitHub Desktop.
<cffunction name="genSalt" access="public" returnType="string">
<cfargument name="size" type="numeric" required="false" default="16" />
<cfscript>
var byteType = createObject('java', 'java.lang.Byte').TYPE;
var bytes = createObject('java','java.lang.reflect.Array').newInstance( byteType , size);
var rand = createObject('java', 'java.security.SecureRandom').nextBytes(bytes);
return toBase64(bytes);
</cfscript>
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment