Skip to content

Instantly share code, notes, and snippets.

@duritong
Created July 6, 2011 15:27
Show Gist options
  • Save duritong/1067518 to your computer and use it in GitHub Desktop.
Save duritong/1067518 to your computer and use it in GitHub Desktop.
SSHA512
require 'rubygems'
require 'digest/sha2'
require 'active_support'
def password(pass)
salt = 32.times.collect { (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }.join
"{SSHA512}#{ActiveSupport::Base64.encode64s(Digest::SHA512.digest(pass + salt)+salt)}"
end
puts password(ARGV.first)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment