Skip to content

Instantly share code, notes, and snippets.

@cowboycoded
Created April 11, 2011 19:11
Show Gist options
  • Save cowboycoded/914090 to your computer and use it in GitHub Desktop.
Save cowboycoded/914090 to your computer and use it in GitHub Desktop.
require 'bcrypt'
module Lock
class CreatePasswordFileGenerator < Rails::Generators::Base
argument :password, :type => :string
source_root File.expand_path('../templates', __FILE__)
def create_password_file
password_salt = BCrypt::Engine.generate_salt
password_hash = BCrypt::Engine.hash_secret(password, password_salt)
create_file "config/lock_password", "#{password_hash}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment