Code Monkey home page Code Monkey logo

crc32.net's People

Contributors

aersh avatar force-net avatar jeffward01 avatar josepineiro avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crc32.net's Issues

Dont work

If you create a new .txt and only write number 1, the crc32 is 83dcefb7. But with your code the crc32 is 2212294583

This 2 code return the same number 2212294583
1
var bytes = File.ReadAllBytes(path);
var crc32 = Crc32Algorithm.Compute(bytes);
2
var crc = 0u;
using (var f = File.OpenRead("somefile"))
{
var buffer = new byte[65536];
while (true)
{
var count = f.Read(buffer, 0, buffer.Length);
if (count == 0)
break;
crc = Crc32Algorithm.Append(crc, buffer, 0, count);
}
}
Console.WriteLine(crc);

The code by kgamecarter don't work
using (var stream = new FileStream(path, FileMode.Open))
using (var crc = new Crc32Algorithm())
{
var crc32bytes = crc.Compute(stream);
var crc32 = BitConverter.ToUInt32(crc32bytes, 0);
}

Parameters?

Hello there,
Maybe I missed something obvious, but I cannot find how you fixed the parameters, nor how I can change those
I don't even know where to find the poly you used and how I can change it if possible

Could you show me where to find those info?
Thanks =)

support chaining style code

as-is

var crc = CrcAlgorithm.CreateCrc16CcittFalse();

// Give it some bytes to chew on - you can call this multiple times if needed
crc.Append(Encoding.ASCII.GetBytes("Hurray for cake!"));

// Get the output - as a hex string, byte array or unsigned integer
Console.WriteLine(crc.ToHexString());

to-be

var crc = CrcAlgorithm
.CreateCrc16CcittFalse()
.Append(Encoding.ASCII.GetBytes("Hurray for cake!"));

Console.WriteLine(crc.ToHexString());

Support for stream

I was wondering if you could add support for FileStream (or Stream in general)?

Since we usually use files for computing the CRC, I find it annoying to load the file in memory in order to get all the bytes. When you have big files, it's not really good practice. And I saw that most of libraries use the same interface as yours.

So, that's what I can do right now:

var bytes = File.ReadAllBytes(path);
var crc32 = Crc32Algorithm.Compute(bytes);

What would be nice:

using (var stream = new FileStream(path, FileMode.Open))
{
    var crc32 = Crc32Algorithm.Compute(stream);
}

Thanks

Incorrect usage of ArgumentOutOfRangeException

throw new ArgumentOutOfRangeException("Selected range is outside the bounds of the input array");

The default constructor should be used instead (remove the parameter).

This text is the default message for the ArgumentOutOfRangeException and so should not be specified. Also, the one-string constructor is not a message-based constructor, it takes the parameter name, so this is not correct usage.

Missing functionality for setting the initial value when using instance methods

I need to calculate a crc32 checksum with LSB bit-ordering and a start value of 0xFFFFFFFF.
This seems to be impossible with this library.

By using the public static uint Append(uint initial, byte[] input, int offset, int length) function, you can specify a start value (by using the uint initial argument to do so). However it is not possible to specify the bit-ordering when using the static functions.

It is possible to specify the bit-ordering by instantiating the public class Crc32Algorithm : HashAlgorithm via the constructor argument bool isBigEndian. However, using an instance it is not possible to set a start value since public abstract class HashAlgorithm : IDisposable, ICryptoTransform has no functionality for it.

Support CRC32/MPEG2 ?

Support CRC32/MPEG2 ?

Result = 0x81972D5B
Check = 0x0376E6E7
INIT = 0xFFFFFFFF
POLY = 0x04C11DB7
XorOut = 0x00000000
REFIN = false
REFOUT = false

FYI: Unsafe rewrite + Intrinsics

I used your code in my CRC32 implementation and did some benchmarks:
Spreads/Spreads@1a6b6c2

CRC32 Managed in every benchmark is code from this repo rewritten to avoid virtual method calls and works with pointers. The numbers are in MB/sec.

The main point was to use hardware intrinsics and your code is the fastest managed fallback I have found.

Thanks!

Warning on .Net Core 2.0

I have a warning at VS 2017 with 1.1.0 version

Warning NU1603 Crc32.NET 1.1.0 depends on NETStandard.Library (>= 1.3.0) but NETStandard.Library 1.3.0 was not found. An approximate best match of NETStandard.Library 1.6.0 was resolved.

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.