AES encrypt library

Started by ckupen, Dec 08, 2022, 04:44 AM

Previous topic - Next topic

ckupen

An API for AES encryption

Have stream encryption with Output feedback mode (OFB)

Link: <https://gist.github.com/zyxkad/a5e02d16d244b20b026ecfb06f662210>

ckupen

Usage:

```lua
os.loadAPI('aes.lua')

key = string.rep('0', 16) -- A 16 bytes key, DO NOT use repeat bytes if you want safety
cipher = aes.Cipher:new(nil, key)
sec = cipher:encrypt("Hello world") -- data can be any length

data = cipher:decrypt(sec) -- Be careful, each decrypt must match a encrypt, you cannot jump off any data
print('data is:', data)

```

sigma-octantis

Quote from: ckupen on Dec 08, 2022, 04:49 AMUsage:

```lua
os.loadAPI('aes.lua')

key = string.rep('0', 16) -- A 16 bytes key, DO NOT use repeat bytes if you want safety
cipher = aes.Cipher:new(nil, key)
sec = cipher:encrypt("Hello world") -- data can be any length

data = cipher:decrypt(sec) -- Be careful, each decrypt must match a encrypt, you cannot jump off any data
print('data is:', data)

```

Looks cool! I would change two things tho (They're very simple), return a table and use
require(), and maybe the gist link (If you click, appears broken at first).
(Basically os.loadAPI is deprecated)

But with that tweaks, I'll probably use it on my server!

Nice work
Check out Saturnus - a language that compiles to lua
You'll be surprised how modern languages can simplify development!

Also check out my ComputerCraft scripts repository!