Coder Social home page Coder Social logo

biscuit's Introduction

Build Status

Biscuit

A Clojure library for calculating message digest(ive)s. The digest algorithms implemented in biscuit are all variations of CRCs and are designed to verify the integrity of messages sent over noisy channels.

Installation

Add the following dependency to your project.clj file:

[magnet/biscuit "1.1.0"]

Usage

Digests can be calculated on raw byte arrays or on strings. When calculated on strings, they need to be converted to raw bytes arrays. In that case, you can specify the character encoding of the string. If you don't specify it, UTF-8 encoding is used by default.

user> (require '[biscuit.core :as digest])
nil
user> (digest/crc8 (byte-array [195, 161, 195, 169, 195, 173, 195, 179, 195, 186]))
166
user> (digest/crc8 (byte-array [225, 0, 233, 0, 237, 0. 243, 0, 250, 0]))
203
user> (digest/crc8 "hobnob")
17
user> (digest/crc8 "áéíóú")
166
user> (digest/crc8 "áéíóú" "UTF-8")
166
user> (digest/crc8 "áéíóú" "ISO-8859-1")
7
user> (digest/crc8 "áéíóú" "UTF-16LE")
203
user> 

The following algorithms are supported:

  • CRC1
  • CRC5
  • CRC8
  • CRC8 1-wire
  • CRC16
  • CRC16 CCITT
  • CRC16 DNP
  • CRC16 Modbus
  • CRC16 USB
  • CRC16 XModem
  • CTC16 ZModem
  • CRC24
  • CRC32
  • CRC32c
  • CRC32 MPEG
  • CRC64

Performance notice: CRC64 implementation uses BigIntegers, as native Clojure Longs and BigInts are not big enough to hold the required values. This means the CRC64 implementation is extremely slow compared to the rest of the CRCs implemented by the library.

Credit

This library is strongly influenced by the digest-crc ruby gem.

License

Copyright © 2012 Henry Garner Copyright © 2019 Magnet S. Coop.

Distributed under the Eclipse Public License, the same as Clojure.

biscuit's People

Contributors

iarenaza avatar henrygarner avatar

Watchers

James Cloos avatar

biscuit's Issues

.getBytes called without charset

(Imported from henrygarner#1)

Hi,

Not sure if this library is being maintained, but hopefully you'll see this

I had different CRC32 checksums returned for the same string on different machines, because .getBytes is called without specifying a character encoding. The default encoding will be used, which is unspecified.

I believe you should be calling it with utf-8 specified.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.