Module: Authentication::Logic::Random

Defined in:
lib/auth/logic/random.rb

Overview

Generates random strings using ruby’s SecureRandom library.

Class Method Summary collapse

Class Method Details

.friendly_tokenObject

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.



13
14
15
# File 'lib/auth/logic/random.rb', line 13

def self.friendly_token
  SecureRandom.urlsafe_base64(15)
end

.hex_tokenObject



7
8
9
# File 'lib/auth/logic/random.rb', line 7

def self.hex_token
  SecureRandom.hex(64)
end