Sha256: 6d80165e0bb7022725c092515d22d4c790bcce501c30f906800274df4539a4fa
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
# coding: ascii-8bit require 'spec_helper' describe Digest::SipHash do let :seed do (0..0x0f).to_a.pack("C16") end it "initialize" do expect(SipHash.new).to be_a_kind_of(StringBuffer) end it "DEFAULT_SEED" do expect(SipHash::DEFAULT_SEED).to eq("\x00" * 16) end it "seed" do sip = SipHash.new expect(sip.seed).to eq("\x00" * 16) end it "seed=" do sip = SipHash.new sip.seed = seed expect(sip.seed).to eq(seed) end it "digest" do expect(SipHash.digest("")).to eq("\x1e\x92\x4b\x9d\x73\x77\x00\xd7") expect(SipHash.digest("", seed)).to eq("\x72\x6f\xdb\x47\xdd\x0e\x0e\x31") expect(SipHash.digest("\x00", seed)).to eq("\x74\xf8\x39\xc5\x93\xdc\x67\xfd") expect(SipHash.digest("\x00\x01", seed)).to eq("\x0d\x6c\x80\x09\xd9\xa9\x4f\x5a") end it "hexdigest" do expect(SipHash.hexdigest("")).to eq("1e924b9d737700d7") expect(SipHash.hexdigest("", seed)).to eq("726fdb47dd0e0e31") expect(SipHash.hexdigest("\x00", seed)).to eq("74f839c593dc67fd") expect(SipHash.hexdigest("\x00\x01", seed)).to eq("0d6c8009d9a94f5a") end it "rawdigest" do expect(SipHash.rawdigest("")).to eq(0x1e924b9d737700d7) expect(SipHash.rawdigest("", seed)).to eq(0x726fdb47dd0e0e31) expect(SipHash.rawdigest("\x00", seed)).to eq(0x74f839c593dc67fd) expect(SipHash.rawdigest("\x00\x01", seed)).to eq(0x0d6c8009d9a94f5a) end it "instance digest" do sip = SipHash.new sip.update "" expect(sip.digest).to eq("\x1e\x92\x4b\x9d\x73\x77\x00\xd7") expect(sip.to_i).to eq(0x1e924b9d737700d7) sip.seed = seed expect(sip.digest).to eq("\x72\x6f\xdb\x47\xdd\x0e\x0e\x31") expect(sip.to_i).to eq(0x726fdb47dd0e0e31) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
digest-siphash-0.0.1 | spec/digest_spec.rb |