Module: Istat::Utils

Defined in:
lib/istat/utils.rb

Class Method Summary collapse

Class Method Details

.uuid(size = 16) ⇒ String

generate a pseudo random uuid based on openssl random

Examples:

Istat::Utils.uuid # => '19be1f6285ae9019254c93a880db7285'

Returns:

  • (String)

    the generated uuid



29
30
31
32
33
# File 'lib/istat/utils.rb', line 29

def self.uuid(size = 16)
  OpenSSL::Random.random_bytes(size).unpack("C" * size).map do |char| 
    "%02x" % char
  end.join
end