Skip to content

Instantly share code, notes, and snippets.

@evanwalsh
Created January 24, 2011 21:13
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 evanwalsh/793971 to your computer and use it in GitHub Desktop.
Save evanwalsh/793971 to your computer and use it in GitHub Desktop.
A function I wrote. Don't know if I'll ever need it.
def generate_salt(length)
salt = String.new
32.times { salt += Kernel.rand(9999).to_s }
if salt.length > length
salt[0, length.to_i]
else
salt
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment