Giter Site home page Giter Site logo

md5.lua's Introduction

md5.lua Build Status

This pure-Lua module computes md5 in Lua 5.1, Lua 5.2 and LuaJIT, using native bit-manipulation libraries when available, and falling back to table-based manipulation of integers in 5.1.

It implements md5.sum and md5.sumhex like the kernel project md5 package, but it's done completely in Lua, with no dependencies on other libs or C files.

Usage

Simple example:

local md5 = require 'md5'

local md5_as_data  = md5.sum(message)       -- returns raw bytes
local md5_as_hex   = md5.sumhexa(message)   -- returns a hex string
local md5_as_hex2  = md5.tohex(md5_as_data) -- returns the same string as md5_as_hex

Incremental example (for computing md5 of streams, or big files which have to be loaded in chunks - new since 1.1.0):

local m = md5.new()
m:update('some bytes')
m:update('some more bytes')
m:update('etc')
return md5.tohex(m:finish())

Credits

This is a cleanup of an implementation by Adam Baldwin - https://gist.github.com/evilpacket/3647908

Which in turn was a mix of the bitwise lib, http://luaforge.net/projects/bit/ by hanzhao (abrash_han - at - hotmail.com), and http://equi4.com/md5/md5calc.lua, by Equi 4 Software.

Lua 5.2 and LuaJIT compatibility by Positive07

A very important fix and the incremental variant by pgimeno

License

This library, as well as all the previous ones in which is based, is released under the MIT license (See license file for details).

Specs

The specs for this library are implemented with busted. In order to run them, install busted and then:

cd path/to/where/the/spec/folder/is
busted

Install

Either copy the file or using luarocks:

luarocks install --server=http://luarocks.org/manifests/kikito md5

md5.lua's People

Contributors

kikito avatar pablomayobre avatar

Watchers

James Cloos avatar Jackson 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.