Created
November 30, 2013 19:45
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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