Module: Kameleoon::Utils::Hasher
- Defined in:
- lib/kameleoon/utils.rb
Class Method Summary collapse
- .calculate(string_to_hash) ⇒ Object
- .obtain(visitor_code, container_id, suffix = nil) ⇒ Object
- .obtain_hash_for_me_group(visitor_code, me_group_name) ⇒ Object
Class Method Details
.calculate(string_to_hash) ⇒ Object
45 46 47 48 49 |
# File 'lib/kameleoon/utils.rb', line 45 def self.calculate(string_to_hash) parsed_value = Digest::SHA256.hexdigest(string_to_hash.encode('UTF-8')).to_i(16) max_value = BigDecimal('2')**BigDecimal('256') (parsed_value / max_value).round(16) end |
.obtain(visitor_code, container_id, suffix = nil) ⇒ Object
37 38 39 |
# File 'lib/kameleoon/utils.rb', line 37 def self.obtain(visitor_code, container_id, suffix = nil) calculate("#{visitor_code}#{container_id}#{suffix}") end |
.obtain_hash_for_me_group(visitor_code, me_group_name) ⇒ Object
41 42 43 |
# File 'lib/kameleoon/utils.rb', line 41 def self.obtain_hash_for_me_group(visitor_code, me_group_name) calculate("#{visitor_code}#{me_group_name}") end |