Sha256: dabd3dc02afaebf6df1f1fc74c95b1765ab73e6af074d389e57891eb82ecd169

Contents?: true

Size: 574 Bytes

Versions: 1

Compression:

Stored size: 574 Bytes

Contents

module Authlogic
  # Handles generating random strings. If SecureRandom is installed it will default to this and use it instead. SecureRandom comes with ActiveSupport.
  # So if you are using this in a rails app you should have this library.
  module Random
    extend self

    SecureRandom = (defined?(::SecureRandom) ? ::SecureRandom : ActiveSupport::SecureRandom)

    def hex_token
      SecureRandom.hex(64)
    end
    
    def friendly_token
      # use base64url as defined by RFC4648
      SecureRandom.base64(15).tr('+/=', '').strip.delete("\n")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Empact-authlogic-3.1.0 lib/authlogic/random.rb