Code Monkey home page Code Monkey logo

crc.jl's Introduction

Build Status Coverage Status

CRC

This is a Julia module for calculating Cyclic Redundancy Checksums (CRCs).

  • All the algorithms in the RevEng Catalogue are supported.

  • New algorithms can be easily added.

  • Calculation can be direct or via cached tables.

  • Speed is comparable to optimized C (checked against CRC32 in libz).

  • Only arrays of bytes are accepted as data (it's certainly possible to handle arbitrary sized sequences; previous versions did this, but it complicated the code for little practical gain so I removed it - please contact me if you want me to add it back).

Examples

Calculate a CRC-32 Sum

julia> using CRC

julia> crc32 = crc(CRC_32)
(anonymous function)

julia> crc32("123456789")
0xcbf43926

The function crc() constructs a lookup table, which is cached in the returned function (here, crc32()). Re-using crc32() to calculate a series of CRCs is therefore more efficient than starting with crc() each time.

The returned function can also be called with a file handle, so calling open(crc32, file) will return the checksum of file.

Within Your Program

The same example as above, but inside your program, would look like this:

using CRC
...
crc32 = crc(CRC_32)  # create our own crc function, just once
...
function some_func(...)
    ...
    x = crc32(data)  # use the crc function created above, many times
    ...
end
...

Force Direct (Tableless) Calculation

julia> crc(CRC_32, tables=NoTables)("123456789")
0xcbf43926

Define an Algorithm

For example, CRC-7, catalogued as width=7 poly=0x09 init=0x00 refin=false refout=false xorout=0x00 check=0x75 name="CRC-7"

julia> myCRC7 = spec(7, 0x09, 0x00, false, false, 0x00, 0x75)
CRC.Spec{UInt8}(7, 0x09, 0x00, false, false, 0x00, 0x75)

julia> @assert crc(myCRC7)(CHECK) == myCRC7.check

Of course, this is already defined:

julia> CRC_7
CRC.Spec{UInt8}(7, 0x09, 0x00, false, false, 0x00, 0x75)

Installation

Julia can be downloaded here. Once Julia is working you can install this package using:

julia> Pkg.add("CRC")

Versions

  • 4.0.0 - 2020-11-27 Remove command line functionality.

  • 3.1.0 - 2020-11-07 Update ArgParse dependency and add Project.toml.

  • 3.0.0 - 2018-02-28 Update for Julia 1.0

  • 1.2.0 - 2016-09-28 Drop Julia 0.3 support and switch to Libz.

  • 1.1.0 - 2015-06-09 Small fixes for Julia 0.4, Travis + Coverage.

  • 1.0.0 - 2014-06-31 Changed handler method so that a String is converted to bytes (instead of being treated as a file path). This will break existing code that uses the current handler (sorry!), but I hope I don't have many users (particularly users that are calling that method)!

  • 0.2.0 - Initial release(s).

crc.jl's People

Watchers

 avatar

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.