https://github.com/tengattack/gluacrypto
A native Go implementation of crypto library for the GopherLua VM.
https://github.com/tengattack/gluacrypto
Last synced: 10 months ago
JSON representation
A native Go implementation of crypto library for the GopherLua VM.
- Host: GitHub
- URL: https://github.com/tengattack/gluacrypto
- Owner: tengattack
- License: mit
- Created: 2018-09-15T07:06:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-24T20:01:46.000Z (about 2 years ago)
- Last Synced: 2024-06-20T19:26:40.052Z (almost 2 years ago)
- Language: Go
- Size: 10.7 KB
- Stars: 5
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LuaCrypto for GopherLua
A native Go implementation of crypto library for the [GopherLua](https://github.com/yuin/gopher-lua) VM.
## Using
### Loading Modules
```go
import (
"github.com/tengattack/gluacrypto"
)
// Bring up a GopherLua VM
L := lua.NewState()
defer L.Close()
// Preload LuaCrypto modules
gluacrypto.Preload(L)
```
### Encoding
* base64
### Hashing
* crc32
* md5
* sha1
* sha256
* sha512
* hmac
```lua
crypto.md5(input [, raw])
-- ...crc32, sha1, sha256, sha512
crypto.hmac(dtype, input, key [, raw])
```
If you need raw data output, set `raw` to `true`.
### Encrypt/Decrypt Chiper Method
* des-ecb
* des-cbc
* aes-cbc (key supports 128, 256, etc.)
```lua
crypto.encrypt(input, cipher, key, options, iv)
crypto.decrypt(input, cipher, key, options, iv)
```
If you need raw data input/output, using `crypto.RAW_DATA` as `options`, otherwise set it to 0.
## License
MIT