如何解密带有Taifun AES-Extension的PHP中的文本?

问题描述 投票:0回答:1

我正在尝试使用appinventor扩展名,该扩展名使用“ AES 128, CBC, and PKCS5 padding”对文本进行加密。我已经尝试了很多,但是无法解密PHP(7.2.9)服务器上的文本。

this site上,他描述了他使用的library,但我无法在php中使用它。

openssl_decript将描述AES-128-CBC,但它无法解密扩展名已加密的消息。该扩展程序使用密码和从应用程序中的密码生成的盐进行加密。

我的PHP服务器代码:

(index.php)
<?php
$password = $_POST["pw"];
$salt = $_POST["salt"];
$iv_mac_text = $_POST["text"];

$method = "AES-128-CBC";
$keyLength = 16;
$iterations = 10000;

echo "Iv, mac and text:$iv_mac_text \n --------------- \n";
echo "Salt:$salt \n --------------- \n";
echo "Password:$password \n --------------- \n";

$saltdecoded = base64_decode($salt);

$generated_key = openssl_pbkdf2($password, $saltdecoded, $keyLength, $iterations, 'sha1');

$keyencoded = base64_encode($generated_key);
echo "confidentialityKey:$keyencoded \n --------------- \n";

$exploded = explode(":", $iv_mac_text);
$iv = base64_decode($exploded[0]);
$mac = base64_decode($exploded[1]);
$encryptedtext = base64_decode($exploded[2]);

$decrypted = openssl_decrypt($exploded[2], $method, $keyencoded,  OPENSSL_ZERO_PADDING, $iv);

$textlength = strlen($decrypted);
echo "Decrypted text ($textlength chars): $decrypted \n --------------- \n";
?>

我为测试而创建的应用程序:

Screenblockeditor

您可以下载apk。对于服务器地址,请在第一个文本框中输入该地址(不带空格):(示例填写您自己的服务器地址)http://your.domain/your/directory/index.php

php encryption aes app-inventor
1个回答
0
投票

我制作了一个PHP库来解密Taifuns和Tiziano1960(两者都是有效的,因为它们基于相同的JAVA库)。您会找到所有信息here

© www.soinside.com 2019 - 2024. All rights reserved.