Sha256: 5011d3e4a61220a26f5f4b22a7b98503657aeac11a8f94d207671b82be173e2f
Contents?: true
Size: 824 Bytes
Versions: 2
Compression:
Stored size: 824 Bytes
Contents
require 'digest/simple' module Digest class Prime31 < Simple def initialize @prime = 31 super end def finish result = 0 @buffer.unpack("C*").each do |c| result += (c * @prime) end [result & 0xffffffff].pack("N") end end end describe Digest::Simple do it "#initialize" do expect(Digest::Simple.new).to be_a_kind_of(Digest::Class) end it "#update" do s = Digest::Prime31.new expect(s.update("abc").object_id).to eq(s.object_id) end it "#reset" do s = Digest::Prime31.new expect(s.hexdigest).to eq("00000000") s.update("abc") expect(s.hexdigest).to eq("0000239a") expect(s.reset.hexdigest).to eq("00000000") end it ".hexdigest" do expect(Digest::Prime31.hexdigest("abc" * 1000)).to eq("008b1190") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
digest-simple-1.1.0 | spec/simple_spec.rb |
digest-simple-1.0.0 | spec/simple_spec.rb |