Last active
June 5, 2017 11:17
-
-
Save Bodacious/ce465716a83ab7b0139e3db03f79c2c6 to your computer and use it in GitHub Desktop.
Random password generator in Ruby on Rails
This file contains hidden or 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
# Examples: | |
# | |
# @password = RandomPassword.password | |
# | |
class RandomPassword | |
class << self | |
delegate :password, to: new | |
end | |
attr_reader :password | |
def initialize(length = 8) | |
@password = SecureRandom.hex((length / 2.0).ceil) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment