No description, website, or topics provided.
C Lua Batchfile C++ Shell
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 2 commits ahead of moteus:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.appveyor
.travis
examples
rockspecs
src
test
.gitignore
.travis.yml
LICENSE
README.md
appveyor.yml
lakeconfig.lua
lakefile

README.md

lua-bgcrypto-sha

Build Status Build status Coverage Status

Digest API

Digest.new() => Digest context

Each MESSAGE can be present like

  • message [,offset=1 [, size=<END OF MESSAGE>]] if message is string
  • message [,offset=1], size if message is raw pointer to memory (light userdata)

Digest.digest(MESSAGE [, text = false]) => string

Digest.pbkdf2(password, salt, iterations, key_length) => string

digest:update(MESSAGE) => self

digest:digest([MESSAGE ,] [text = false]) => self

digest:reset() => self

digest:clone() => self

HMAC API

Digest.hmac.new(key) => HMAC Context

Digest.hmac.digest(key, MESSAGE[, text = false]) => string

hmac:update(MESSAGE) => self

hmac:digest([MESSAGE ,] [text = false]) => self

hmac:reset([key]) => self

hmac:clone() => self

Usage

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.

Bitdeli Badge