Class: Apullo::Hash
- Inherits:
-
Object
- Object
- Apullo::Hash
- Defined in:
- lib/apullo/hash.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(data) ⇒ Hash
constructor
A new instance of Hash.
- #md5 ⇒ Object
- #mmh3 ⇒ Object
- #sha1 ⇒ Object
- #sha256 ⇒ Object
Constructor Details
#initialize(data) ⇒ Hash
10 11 12 |
# File 'lib/apullo/hash.rb', line 10 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/apullo/hash.rb', line 8 def data @data end |
Instance Method Details
#md5 ⇒ Object
22 23 24 |
# File 'lib/apullo/hash.rb', line 22 def md5 Digest::MD5.hexdigest data end |
#mmh3 ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/apullo/hash.rb', line 26 def mmh3 hash = MurmurHash3::V32.str_hash(data) if (hash & 0x80000000).zero? hash else -((hash ^ 0xFFFFFFFF) + 1) end end |
#sha1 ⇒ Object
14 15 16 |
# File 'lib/apullo/hash.rb', line 14 def sha1 Digest::SHA1.hexdigest data end |
#sha256 ⇒ Object
18 19 20 |
# File 'lib/apullo/hash.rb', line 18 def sha256 Digest::SHA256.hexdigest data end |