Class: BitJWT::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/bitjwt/util.rb

Class Method Summary collapse

Class Method Details

.base64url_encode(str) ⇒ Object



12
13
14
# File 'lib/bitjwt/util.rb', line 12

def base64url_encode(str)
  Base64.encode64(str).tr('+/', '-_').gsub(/[\n=]/, '')
end

.bin_to_hex(bin) ⇒ Object



8
9
10
# File 'lib/bitjwt/util.rb', line 8

def bin_to_hex(bin)
  bin.unpack('H*')[0]
end

.hex_to_bin(hex) ⇒ Object



4
5
6
# File 'lib/bitjwt/util.rb', line 4

def hex_to_bin(hex)
  [hex].pack('H*')
end