Module: OAuth2::Provider::Random::Base62

Defined in:
lib/oauth2/provider/random.rb

Constant Summary collapse

CHARS =
('0'..'9').to_a + ('a'..'z').to_a + ('A'..'Z').to_a

Class Method Summary collapse

Class Method Details

.encode(i) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/oauth2/provider/random.rb', line 9

def self.encode(i)
  return '0' if i == 0
  s = ''
  while i > 0
    s << CHARS[i.modulo(62)]
    i /= 62
  end
  s.reverse!
  s
end