Code Monkey home page Code Monkey logo

nim-crc32's Introduction

CRC32

CRC32 for Nim, 2 proc. Its just a proc so no much to document about it, just pass the thingy you want to do CRC.

  • Works with --gc:arc, --gc:orc, --panics:on, --experimental:strictFuncs, C, C++, JavaScript.
  • Uses system.nim only, does not import anything from stdlib. Works in-place, can out-place using sugar.dup.

Use

from std/sugar import dup  # Optional, to out-place.

var x = "The quick brown fox jumps over the lazy dog."
crc32(x)  ## In-Place.
doAssert x == "519025E9"
doAssert "The quick brown fox jumps over the lazy dog.".dup(crc32) == "519025E9"  ## Out-Place.

var e = " "
crc32(e)  ## In-Place.
doAssert e == "E96CCF45"
doAssert " ".dup(crc32) == "E96CCF45"  ## Out-Place.

var z = ""
crc32(z)   ## In-Place.
doAssert z == "00000000"
doAssert "".dup(crc32) == "00000000"  ## Out-Place.

var f = "crc32.nim"
crc32FromFile(f)  ## In-Place.
echo f
echo "crc32.nim".dup(crc32FromFile)  ## Out-Place.

Install

nimble install crc32

Stars

@juancarlospaco@adokitkat@elcritch@hamidb80@amit-gshe

nim-crc32's People

Contributors

0xace avatar adokitkat avatar amit-gshe avatar barroff avatar elcritch avatar hamidb80 avatar juancarlospaco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nim-crc32's Issues

Incorrect initial value; should be FFFFFFFF not 0

FYI, your implementation starts with the wrong initial value. It should be 0xFFFFFFFF, not 0.

const InitCrc32* = TCrc32(0)

If you're only using your own code to both generate and check CRCs this isn't a problem, but if you want to verify digests generated by anyone else (or vice versa), this would need to be fixed.

I've made this change in my own forked code and can attest that it works correctly (at least that it matches values generated by the crc32 function in zlib.)

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.