module SecureRandom

Older versions of SecureRandom (e.g. in 1.8.7) don’t have the uuid method

Public Class Methods

uuid() click to toggle source
# File lib/puppet/util/monkey_patches.rb, line 218
def self.uuid
  # Copied from the 1.9.1 stdlib implementation of uuid
  ary = self.random_bytes(16).unpack("NnnnnN")
  ary[2] = (ary[2] & 0x0fff) | 0x4000
  ary[3] = (ary[3] & 0x3fff) | 0x8000
  "%08x-%04x-%04x-%04x-%04x%08x" % ary
end