Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moteus/lua-bgcrypto-sha
https://github.com/moteus/lua-bgcrypto-sha
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/moteus/lua-bgcrypto-sha
- Owner: moteus
- License: bsd-2-clause
- Created: 2013-11-19T12:35:14.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2019-05-05T13:36:53.000Z (over 5 years ago)
- Last Synced: 2024-10-17T16:11:00.074Z (27 days ago)
- Language: C
- Size: 106 KB
- Stars: 4
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
lua-bgcrypto-sha
================
[![Build Status](https://travis-ci.org/moteus/lua-bgcrypto-sha.png?branch=master)](https://travis-ci.org/moteus/lua-bgcrypto-sha)
[![Build status](https://ci.appveyor.com/api/projects/status/j060vyw45e5fohgb?svg=true)](https://ci.appveyor.com/project/moteus/lua-bgcrypto-sha)
[![Coverage Status](https://coveralls.io/repos/github/moteus/lua-bgcrypto-sha/badge.svg?branch=master)](https://coveralls.io/github/moteus/lua-bgcrypto-sha?branch=master)## Digest API ##
### Digest.new() => Digest context
### Each MESSAGE can be present like
* `message [,offset=1 [, size=]]` 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 ##
```Lua
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](examples/AesFileEncrypt.lua) implementation using `lua-bgcrypto` library.
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/moteus/lua-bgcrypto-sha/trend.png)](https://bitdeli.com/free "Bitdeli Badge")