Skip to content

Instantly share code, notes, and snippets.

@Bodacious
Last active June 5, 2017 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bodacious/ce465716a83ab7b0139e3db03f79c2c6 to your computer and use it in GitHub Desktop.
Save Bodacious/ce465716a83ab7b0139e3db03f79c2c6 to your computer and use it in GitHub Desktop.
Random password generator in Ruby on Rails
# 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