Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Ruby: Readable random strings for coupons or tokens
Ruby
tree: c1d90e338b

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
README.markdown
Rakefile.rb
VERSION
init.rb
readable_random.gemspec

README.markdown

Readable string for coupon codes or auth tokens, something people can read/write and do not confuse.

  • more information density than hex -> shorter codes
  • less confusion than base64 -> readable codes

Install

  • As Rails plugin: script/plugin install git://github.com/grosser/readable_random.git
  • As gem: sudo gem install grosser-readable_random --source http://gems.github.com

Usage

ReadableRandom.get(5) -> 'aB23r'

# user.rb
def generate_token
  while token.blank? or User.find_by_token(token)
    self.token = ReadableRandom.get(6)
  end
end

TODO

  • prevent nasty words by not using vovels or a more clever tick...

AUTHOR

Michael Grosser
grosser.michael@gmail.com
Hereby placed under public domain, do what you want, just do not hold me accountable...

Something went wrong with that request. Please try again.