Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/revise/core_ext/string.rb

Class Method Summary collapse

Class Method Details

.friendly_tokenObject



2
3
4
# File 'lib/revise/core_ext/string.rb', line 2

def self.friendly_token
  SecureRandom.base64(15).tr('+/=lIO0', 'pqrsxyz')
end

.secure_compare(a, b) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/revise/core_ext/string.rb', line 6

def self.secure_compare(a, b)
  return false if a.blank? || b.blank? || a.bytesize != b.bytesize
  l = a.unpack "C#{a.bytesize}"

  res = 0
  b.each_byte { |byte| res |= byte ^ l.shift }
  res == 0
end