Module: Xipai::HashcodeGenerator

Defined in:
lib/xipai/hashcode_generator.rb

Class Method Summary collapse

Class Method Details

.generate_or_existing(hashcode) ⇒ Object



19
20
21
22
# File 'lib/xipai/hashcode_generator.rb', line 19

def generate_or_existing(hashcode)
  return random_hashcode if ["", nil].include?(hashcode)
  return hashcode
end

.random_hashcodeObject



12
13
14
15
16
17
# File 'lib/xipai/hashcode_generator.rb', line 12

def random_hashcode()
  digit_seed =
    "#{self.name.object_id}-#{$$}-#{Time.now.to_i}-#{SecureRandom.hex(16)}-#{SecureRandom.hex(16)}}"
  _hashcode_ = Digest::SHA256.hexdigest(digit_seed)[0 .. 16]
  return _hashcode_
end