-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
92 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
name: fnv | ||
version: 0.1.0 | ||
version: 0.1.1 | ||
|
||
authors: | ||
- Ali Naqvi <syed.alinaqvi@gmail.com> | ||
|
||
crystal: 0.34.0 | ||
crystal: 0.35.0 | ||
|
||
license: MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,35 @@ | ||
require "./spec_helper" | ||
|
||
describe FNV do | ||
describe Digest::FNV do | ||
it "Test Hashes" do | ||
# 32bit FNV-1 | ||
digest = Digest::FNV32.digest("foo") | ||
h = IO::ByteFormat::BigEndian.decode(UInt32, digest) # => 1083137555 | ||
h.should eq(1083137555u32) | ||
|
||
# 32bit FNV-1a | ||
digest = Digest::FNV32A.digest("foo") | ||
h = IO::ByteFormat::BigEndian.decode(UInt32, digest) # => 2851307223 | ||
h.should eq(2851307223u32) | ||
|
||
# 64bit FNV-1 | ||
digest = Digest::FNV64.digest("foo") | ||
h = IO::ByteFormat::BigEndian.decode(UInt64, digest) # => 15621798640163566899 | ||
h.should eq(15621798640163566899u64) | ||
|
||
# 64bit FNV-1a | ||
digest = Digest::FNV64A.digest("foo") | ||
h = IO::ByteFormat::BigEndian.decode(UInt64, digest) # => 15902901984413996407 | ||
h.should eq(15902901984413996407u64) | ||
|
||
# 128bit FNV-1 | ||
digest = Digest::FNV128.digest("foo") | ||
h = IO::ByteFormat::BigEndian.decode(UInt128, digest) # => 221377198890555750482995053501755142603 | ||
h.to_s.should eq("221377198890555750482995053501755142603") | ||
|
||
# 128bit FNV-1a | ||
digest = Digest::FNV128A.digest("foo") | ||
h = IO::ByteFormat::BigEndian.decode(UInt128, digest) # => 221385884292107687162785618921601726655 | ||
h.to_s.should eq("221385884292107687162785618921601726655") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# FNV module implements FNV-1 and FNV-1a, non-cryptographic hash functions created by | ||
# Glenn Fowler, Landon Curt Noll, and Phong Vo. | ||
module FNV | ||
VERSION = "0.1.0" | ||
module Digest::FNV | ||
VERSION = "0.1.1" | ||
end | ||
|
||
require "./fnv/**" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters