Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add checksum functions and tobinary functions #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

starwing
Copy link

  • port crc32 and adler32 functions to lua.
  • add a function convert int32 checksum to string.

@starwing
Copy link
Author

Okay, I have added the documents and test cases, and remove the tobinary function :)

@brimworks
Copy link
Owner

Sorry for being slow on the uptake here... after thinking about this a bit, I'm proposing a function factory interface that more closely mirrors the compression interface:

f94aabf

Specifically you can do this:

        -- All in one call:
        local csum = zlib.crc32()("one two")

        -- Multiple calls:
        local compute = zlib.crc32()
        compute("one")
        assert(csum == compute(" two"))

        -- Multiple compute_checksums joined:
        local compute1, compute2 = zlib.crc32(), zlib.crc32()
        compute1("one")
        compute2(" two")
        assert(csum == compute1(compute2))

Feedback is welcomed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants