Module: Webhookdb::Id

Defined in:
lib/webhookdb/id.rb

Constant Summary collapse

ID_BYTES =
16

Class Method Summary collapse

Class Method Details

.new_opaque_id(prefix) ⇒ Object



8
9
10
11
# File 'lib/webhookdb/id.rb', line 8

def self.new_opaque_id(prefix)
  b36 = self.rand_enc(ID_BYTES)
  return "#{prefix}_#{b36}"
end

.rand_enc(blen) ⇒ Object



13
14
15
16
# File 'lib/webhookdb/id.rb', line 13

def self.rand_enc(blen)
  b = SecureRandom.bytes(blen)
  return Digest.hexencode(b).to_i(16).to_s(36)
end