Sha256: d34b3a8471e77a6b31bead6e786cd2b24bb1147d26cc3036fda5fb04ac7d7554

Contents?: true

Size: 529 Bytes

Versions: 7

Compression:

Stored size: 529 Bytes

Contents

# frozen_string_literal: true

require "digest/sha2"
require "murmurhash3"

module Apullo
  class Hash
    attr_reader :data

    def initialize(data)
      @data = data
    end

    def sha1
      Digest::SHA1.hexdigest data
    end

    def sha256
      Digest::SHA256.hexdigest data
    end

    def md5
      Digest::MD5.hexdigest data
    end

    def mmh3
      hash = MurmurHash3::V32.str_hash(data)
      if (hash & 0x80000000).zero?
        hash
      else
        -((hash ^ 0xFFFFFFFF) + 1)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
apullo-0.2.0 lib/apullo/hash.rb
apullo-0.1.5 lib/apullo/hash.rb
apullo-0.1.4 lib/apullo/hash.rb
apullo-0.1.3 lib/apullo/hash.rb
apullo-0.1.2 lib/apullo/hash.rb
apullo-0.1.1 lib/apullo/hash.rb
apullo-0.1.0 lib/apullo/hash.rb