module DigestGenerator
Constants
- MASK_64BIT
- SUPPORTED_ALGORITHMS
- VERSION
- XXHASH_ALGO
Public Class Methods
included(base)
click to toggle source
# File lib/digest_generator.rb, line 43 def self.included(base) base.include(InstanceMethods) end
Public Instance Methods
algorithm()
click to toggle source
# File lib/digest_generator.rb, line 15 def algorithm @algorithm end
algorithm=(value)
click to toggle source
# File lib/digest_generator.rb, line 19 def algorithm=(value) @algorithm = value end
configure_default_algo()
click to toggle source
# File lib/digest_generator.rb, line 23 def configure_default_algo self.algorithm = XXHASH_ALGO if algorithm.nil? || algorithm == '' end
digest_32bit(payload)
click to toggle source
# File lib/digest_generator.rb, line 33 def digest_32bit(payload) configure_default_algo send("#{algorithm.downcase}32_digest", payload) end
digest_63bit(payload)
click to toggle source
Hash 64 and mask bit 63 (0-63) to remove signedness to be compatible with postgress bigints
# File lib/digest_generator.rb, line 28 def digest_63bit(payload) configure_default_algo send("#{algorithm.downcase}63_digest", payload) end
digest_64bit(payload)
click to toggle source
# File lib/digest_generator.rb, line 38 def digest_64bit(payload) configure_default_algo send("#{algorithm.downcase}64_digest", payload) end
Private Instance Methods
xxhash32_digest(payload)
click to toggle source
# File lib/digest_generator.rb, line 79 def xxhash32_digest(payload) XXhash.xxh32(payload) end
xxhash63_digest(payload)
click to toggle source
# File lib/digest_generator.rb, line 71 def xxhash63_digest(payload) XXhash.xxh64(payload) & MASK_64BIT end
xxhash64_digest(payload)
click to toggle source
# File lib/digest_generator.rb, line 75 def xxhash64_digest(payload) XXhash.xxh64(payload) end