Liking cljdoc? Tell your friends :D

zlib-tiny

A Clojure library designed to cover basic needs of packing|unpacking exchange messages, storable chunks etc. And to check their consistency.

zlib tiny

Usage

Add the following to your Leiningen’s project.clj:

[net.tbt-post/zlib-tiny "0.3.1"]
From version v0.3.1 and upward the library requires Java class versions 60.0 and newer, thus if in your needs is to use it with Java 1.8 please switch back to older (0.2.x) version of the library or try to rebuild the library locally.

Compress

ZLib

;; ZLib Example

(bytes->str
 (force-byte-array
  (inflate
   (deflate
    (str->bytes "test it!")))))

(-> "test it!"
    str->bytes
    deflate
    inflate
    force-byte-array
    bytes->str)

GZip

;; GZip Example

(bytes->str
 (gunzip
  (gzip
   (str->bytes "test it!"))))

(-> "test it!"
    str->bytes
    gzip
    gunzip
    bytes->str)

Checksums

CRC

;; CRC32 example
(crc32 (.getBytes "123456789"))
=> 3421780262
;; CRC64 example
(crc64 (.getBytes "123456789"))
=> -7395533204333446662

Digests

$ echo -n 'test it!' | md5
f4214812f0247f69661fd29e0fca6496

$ echo -n 'test it!' | shasum -a 1
1393ce5dfcf39109a420eb583ecfdeacc28c783a  -

$ echo -n 'test it!' | shasum -a 256
9c507d01834b2749d088122a7b3d200957f9b25579b5ce6b490e3b2067ee4f66  -
(import '(org.apache.commons.codec.binary Hex))
(-> "test it!" str->bytes md5 Hex/encodeHex String.)
=> "f4214812f0247f69661fd29e0fca6496"
(-> "test it!" str->bytes sha-1 Hex/encodeHex String.)
=> "1393ce5dfcf39109a420eb583ecfdeacc28c783a"
(-> "test it!" str->bytes sha-256 Hex/encodeHex String.)
=> "9c507d01834b2749d088122a7b3d200957f9b25579b5ce6b490e3b2067ee4f66"

Test

$ lein test

...

lein test zlib-tiny.checksum

lein test zlib-tiny.compress

Ran 3 tests containing 7 assertions.
0 failures, 0 errors.

Manual Build

$ lein install

License

Copyright © 2017-2021

Distributed under the Apache License v 2.0

Can you improve this documentation? These fine people already did:
MelKori & source-c
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close