Module: Eluvia::Uuid
- Defined in:
- lib/eluvia/utils/uuid.rb
Constant Summary collapse
Class Method Summary collapse
Class Method Details
.str_to_uuid(str) ⇒ Object
9 10 11 |
# File 'lib/eluvia/utils/uuid.rb', line 9 def self.str_to_uuid(str) UUIDTools::UUID.sha1_create(NAMESPACE, str.to_s).to_s end |
.str_to_uuid_v2(str) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/eluvia/utils/uuid.rb', line 13 def self.str_to_uuid_v2(str) generator = Random.new(str.consistent_hash.abs) ary = generator.bytes(16) ary.setbyte(6, (ary.getbyte(6) & 0x0f) | 0x40) ary.setbyte(8, (ary.getbyte(8) & 0x3f) | 0x80) ary.unpack("H8H4H4H4H12").join('-') end |