Module: Sinopac::FunBiz::Hash
- Defined in:
- lib/sinopac/funbiz/hash.rb
Class Method Summary collapse
Class Method Details
.hash_id(a1:, a2:, b1:, b2:) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/sinopac/funbiz/hash.rb', line 9 def self.hash_id(a1:, a2:, b1:, b2:) a1a2 = string_xor(str1: a1, str2: a2) b1b2 = string_xor(str1: b1, str2: b2) "#{a1a2}#{b1b2}" end |
.string_xor(str1:, str2:) ⇒ Object
3 4 5 6 7 |
# File 'lib/sinopac/funbiz/hash.rb', line 3 def self.string_xor(str1:, str2:) str1.chars.zip(str2.chars).map { |x, y| (x.to_i(16) ^ y.to_i(16)).to_s(16).upcase }.join end |