Skip to content

Lua built-in module implements common algorithms such as crc, md5, rc, des, aes, base64.

License

Notifications You must be signed in to change notification settings

brinkqiang/luacrypto

Repository files navigation

luacrypto

Copyright (c) 2013-2018 brinkqiang ([email protected])

luacrypto License blog Open Source Love GitHub stars GitHub forks

Build status

Linux Mac Windows
lin-badge mac-badge win-badge

env

install cmake

Intro

luacrypto

win

build.bat
cd bin\relwithdebinfo
lua ..\script\test.lua  

linux

bash build.sh
cd bin\relwithdebinfo
lua ..\script\test.lua  
local luacrypto = require("luacrypto")

local rc = luacrypto.rc4.new()
rc:SetKey("hello world")

local str = rc:Encode("hello world")
print("rc -> " .. rc:Decode(str))

local md5 = luacrypto.md5.new()
local str2 = md5:GetMD5("hello world")
print("md5 -> " .. str2)

local crc = luacrypto.crc.new()
local str3 = crc:GetCRC("hello world")
print("crc -> " .. str3)

local base64 = luacrypto.base64.new()
local str4 = base64:Encode("hello world")
print("base64 -> " .. base64:Decode(str4))

local des = luacrypto.des.new()
local DES3Block = luacrypto.DES3Block.new()
local DES3ContextEncKey = luacrypto.DES3Context.new()
local DES3ContextDecKey = luacrypto.DES3Context.new()

des:DESGenKey(DES3Block)
des:DESGenEncodeKey(DES3ContextEncKey, DES3Block)
des:DESGenDecodeKey(DES3ContextDecKey, DES3Block)

local encode = des:Encode(DES3ContextEncKey, DES3Block, "hello world")

print("des -> " .. encode)

local decode = des:Decode(DES3ContextDecKey, DES3Block, encode)

print("des -> " .. decode)
rc -> hello world
md5 -> 5EB63BBBE01EEED093CB22BB8F5ACDC3
crc -> 222957957
base64 -> hello world
des -> 鑥?剔?;鹰苠嵸
des -> hello world

Contacts

Thanks

About

Lua built-in module implements common algorithms such as crc, md5, rc, des, aes, base64.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published