Skip to content

Instantly share code, notes, and snippets.

@istana
Created November 30, 2013 19:45
Show Gist options
  • Save istana/7723577 to your computer and use it in GitHub Desktop.
Save istana/7723577 to your computer and use it in GitHub Desktop.
Ask for password in ruby command line and do not show characters. And generate salt. Works in rake task.
salt = SecureRandom.base64
puts "Generated salt: #{salt} (only for information)"
passw = ''
puts 'Enter password: '
$stdin.noecho do
passw = $stdin.gets.strip
end
if passw.blank? || passw.length < 6
puts 'Password cannot be empty or shorter than 6 characters'
exit
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment