SHA-1 secure hash computation, and HMAC-SHA1 signature computation in Lua (5.1)
Switch branches/tags
Nothing to show
Clone or download
Latest commit 92d955d Jan 22, 2014
Failed to load latest commit information.
rockspecs fix rockspec Jan 22, 2014
spec initial commit Aug 30, 2013
MIT-LICENSE.txt initial commit Aug 30, 2013 added README Aug 30, 2013
sha1.lua added VERSION, DESCRIPTION, URL and LICENSE fields Sep 14, 2013


This pure-Lua module computes SHA-1 and HMAC-SHA1 signature computations in Lua 5.1.


local sha1 = require 'sha1'

local hash_as_hex   = sha1(message)            -- returns a hex string
local hash_as_data  = sha1.binary(message)     -- returns raw bytes

local hmac_as_hex   = sha1.hmac(key, message)        -- hex string
local hmac_as_data  = sha1.hmac_binary(key, message) -- raw bytes


This is a cleanup of an implementation by Eike Decker -,

Which in turn was based on an original implementation by Jeffrey Friedl -

The original algorithm is


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


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