This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

encode-decode password in apps
#6
Create a user library called aes by using this code:
https://github.com/openresty/lua-resty-s...ty/aes.lua

Add this before ffi.cdef... (line 21) to make it work on LM:
Code:
local lib = '/usr/lib/libcrypto.so'
if not io.exists(lib) then
     lib = '/usr/lib/libcrypto.so.1.0.0'
end
ffi.load(lib, true)

Encrypted data is raw binary so it's additional encoded into base64. CPU unique ID is used instead of MAC address becase MAC can be changed on OS level while CPU ID cannot.
Code:
aes = require('aes')
require('encdec')

key = io.readfile('/proc/device-tree/uniqid')
ctx = aes:new(key)
res = ctx:encrypt('abcdef')
res = encdec.base64enc(res)
log(res)

ctx = aes:new(key)
res = encdec.base64dec(res)
res = ctx:decrypt(res)
log(res)
Reply


Messages In This Thread
encode-decode password in apps - by merel - 10.10.2018, 16:04
RE: encode-decode password in apps - by admin - 10.10.2018, 16:47
RE: encode-decode password in apps - by merel - 10.10.2018, 21:07
RE: encode-decode password in apps - by admin - 13.10.2018, 18:12
RE: encode-decode password in apps - by merel - 15.10.2018, 21:22
RE: encode-decode password in apps - by admin - 22.10.2018, 06:38
RE: encode-decode password in apps - by merel - 25.10.2018, 08:11

Forum Jump: