Skip to content

Commit 33a0923

Browse files
committed
extracted CRC32C for some Intel chips; refactored checksum tests
1 parent babc160 commit 33a0923

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src-clj/zlib_tiny/core.clj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
DeflaterInputStream
77
Deflater
88
ZipException
9-
CRC32)
9+
CRC32 CRC32C)
1010
(zlib_tiny CRC64)
1111
(org.apache.commons.io IOUtils)
1212
(java.security MessageDigest)
@@ -100,6 +100,10 @@
100100
^Long [^bytes b]
101101
(wrap-crc CRC32 b))
102102

103+
(defn crc32c
104+
^Long [^bytes b]
105+
(wrap-crc CRC32C b))
106+
103107
(defn crc64
104108
^Long [^bytes b]
105109
(wrap-crc CRC64 b))

test/zlib_tiny/checksum.clj

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,19 @@
66
(def test-string "test it!")
77

88
(deftest checksums
9-
(testing "CRC32"
10-
(is (= 3421780262 (crc32 (.getBytes "123456789")))))
11-
(testing "CRC64"
12-
(is (= -7395533204333446662 (crc64 (.getBytes "123456789"))))))
9+
(let [input "123456789"
10+
bs (.getBytes input)]
11+
(println "Test input string:" input)
12+
(println "Test input bytes:" (hexlify bs))
13+
(testing "CRC32"
14+
(println "CRC32 checks:")
15+
(is (= 3421780262 (time (crc32 bs))) "CRC32 mismatch"))
16+
(testing "CRC32C"
17+
(println "CRC32C checks:")
18+
(is (= 3808858755 (time (crc32c bs))) "CRC32C mismatch"))
19+
(testing "CRC64"
20+
(println "CRC64 checks:")
21+
(is (= -7395533204333446662 (time (crc64 bs))) "CRC64 mismatch"))))
1322

1423
(deftest digests
1524
(testing "MD5"

0 commit comments

Comments
 (0)