Sha256: da2b3d147e73d511ec3060e912566858dc1b2ce2e26e84bf93dd83dcee86a3fb
Contents?: true
Size: 678 Bytes
Versions: 6
Compression:
Stored size: 678 Bytes
Contents
module Killbill module Plugin module ActiveMerchant class Utils # Use base 62 to be safe BASE62 = ('0'..'9').to_a + ('A'..'Z').to_a + ('a'..'z').to_a def self.compact_uuid(uuid) uuid = uuid.gsub(/-/, '') uuid.hex.base(62).map{ |i| BASE62[i].chr } * '' end def self.unpack_uuid(base62_uuid) as_hex = base62_uuid.split(//).inject(0) { |i,e| i*62 + BASE62.index(e[0]) } no_hyphens = "%x" % as_hex no_hyphens = '0' * (32 - no_hyphens.size) + no_hyphens no_hyphens.insert(8, "-").insert(13, "-").insert(18, "-").insert(23, "-") end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems