Module: Temporal::UUID

Defined in:
lib/temporal/uuid.rb

Class Method Summary collapse

Class Method Details

.v5(uuid_namespace, name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/temporal/uuid.rb', line 7

def self.v5(uuid_namespace, name)
  hash = Digest::SHA1.new
  hash.update(uuid_namespace)
  hash.update(name)

  ary = hash.digest.unpack("NnnnnN")
  ary[2] = (ary[2] & 0x0FFF) | (5 << 12)
  ary[3] = (ary[3] & 0x3FFF) | 0x8000

  "%08x-%04x-%04x-%04x-%04x%08x" % ary
end