message [,offset=1 [, size=<END OF MESSAGE>]]
if message is stringmessage [,offset=1], size
if message is raw pointer to memory (light userdata)
local sha1 = require "bgcrypto.sha1"
local key = "\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11\11"
local msg = "The quick brown fox jumps over the lazy dog"
print(sha1.digest(msg, true))
print(sha1.hmac.digest(key, msg, true))
local ctx = sha1.new()
for i = 1, #msg do ctx:update(msg, i, 1) end
print(ctx:digest(true))
local ctx = sha1.hmac.new(key)
for i = 1, #msg do ctx:update(msg, i, 1) end
print(ctx:digest(true))
print(ctx:reset(key):update(msg:sub(1, 25)):digest(msg:sub(26), true))
print(string.format("%q", sha1.pbkdf2('secret', '123salt', 1000, 32)))
See AesFileEncrypt implementation using lua-bgcrypto
library.