Модуль для шифрования.
Содержит:
- HEX
- Base64
- md5
- sha1
- sha256
- sha512
- AES (Rijndael)
- Salsa20
- RSA
пример использования:
Содержит:
- HEX
- Base64
- md5
- sha1
- sha256
- sha512
- AES (Rijndael)
- Salsa20
- RSA
Lua:
md5(text)
hex_encode(text)
hex_decode(text)
base64_encode(text)
base64_decode(text)
sha1(text)
sha256(text)
sha512(text)
aes_generate_key()
aes_generate_iv()
aes_encode(text,key,iv)
aes_decode(text,key,iv)
salsa20_generate_key()
salsa20_generate_iv()
salsa20_encode(text,key,iv)
salsa20_decode(text,key,iv)
rsa_encode(text,publickey)
пример использования:
Lua:
local crypto = require 'crypto_lua'
print("----------------------------------");
print("md5:",crypto.md5("hello"));
print("hex:",crypto.hex_encode("hello"));
print("base64:",crypto.base64_encode("hello"));
print("sha1:",crypto.sha1("hello"));
print("sha256:",crypto.sha256("hello"));
print("sha512:",crypto.sha512("hello"));
local aes_key = crypto.aes_generate_key();
local aes_iv = crypto.aes_generate_iv();
local salsa_key = crypto.salsa20_generate_key();
local salsa_iv = crypto.salsa20_generate_iv();
print("aes_key:",aes_key);
print("aes_iv:",aes_iv);
print("salsa_key:",salsa_key);
print("salsa_iv:",salsa_iv);
print("AES:",crypto.aes_encode("hello",aes_key,aes_iv));
print("Salsa:",crypto.salsa20_encode("hello",salsa_key,salsa_iv));
print("RSA:",crypto.rsa_encode("hello","MFswDQYJKoZIhvcNAQEBBQADSgAwRwJAd4NbA9sF6oBFc0CyVpYyOAHlsEb6Qjln8CEdILXNj6DZguR9zFEbjUGoVsEqhdDof9fXeUXU1vzC8ivmEeRJ1QIDAQAB"));
print("----------------------------------");
Вложения
Последнее редактирование: