Софт [Module] Crypto

manoaratefy

Новичок
4
0
I tried to use this library to encrypt and send message to a PHP but it seems not working.

My LUA code:
LUA part - Encrypt the text and output it:
local crypto = require 'crypto_lua'
local base64 = require "base64"
local cjson = require "cjson"

local aes_key = crypto.aes_generate_key()
local aes_iv = crypto.aes_generate_iv()

local encrypted = crypto.aes_encode("test", aes_key, aes_iv)

print(cjson.encode({
    key = aes_key,
    iv = aes_iv,
    encrypted = encrypted
}))

The PHP code:
Код:
// Data copied from the printed output of LUA:
$data = 'kEO2PA==';
$key = base64_decode('zOqFI3qTxXd0qKtUrbXQYg==');
$iv = base64_decode('+QqJzwE+3n2Lq6n2WlcO0g==');

// I presume the encryption is AES-192-CBC, I might be wrong
$output = openssl_decrypt($data, 'aes-192-cbc', $key, 0, $iv);
if ($output === false) {
    echo "Error: " . openssl_error_string();
    exit;
}

echo json_encode([
    'data' => $output,
]);

I'm not sure where I did wrong, the openssl_error_string() says "error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length"

Someone can help me?
 

MahdiMz

Новичок
1
0
I have the same issue as the one last post, any update on this? I'm not very familiar with encryption methods but from what I know I tried anything but I failed to decrypt the encrypted strings using any external way than calling the dll's native functions. Do you add an extra keyword to the password or iv to make the strings become decryptable using the dll itself only or I'm doing something wrong?