Sha256: 40e7735cd97477c024896a93d13645989684b111f291117e99bbf7ef8ece97c2

Contents?: true

Size: 421 Bytes

Versions: 11

Compression:

Stored size: 421 Bytes

Contents

require "securerandom"

module Authlogic
  # Generates random strings using ruby's SecureRandom library.
  module Random
    def self.hex_token
      SecureRandom.hex(64)
    end

    # Returns a string in base64url format as defined by RFC-3548 and RFC-4648.
    # We call this a "friendly" token because it is short and safe for URLs.
    def self.friendly_token
      SecureRandom.urlsafe_base64(15)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
authlogic-4.5.0 lib/authlogic/random.rb
authlogic-4.4.3 lib/authlogic/random.rb
authlogic-4.4.2 lib/authlogic/random.rb
authlogic-4.4.1 lib/authlogic/random.rb
authlogic-4.4.0 lib/authlogic/random.rb
authlogic-4.3.0 lib/authlogic/random.rb
authlogic-4.2.0 lib/authlogic/random.rb
authlogic-4.1.1 lib/authlogic/random.rb
authlogic-4.1.0 lib/authlogic/random.rb
authlogic-4.0.1 lib/authlogic/random.rb
authlogic-4.0.0 lib/authlogic/random.rb