解密用aspEncrypt加密的php中的字符串

| 我需要与使用来自assEncrypt的ASP平台进行通信。 谁能提供一个示例,说明如何使用PHP和mcrypt解码通过aspEncrypt例程创建的字符串。 以下链接提供了aspEncrypt的示例页面: http://support.persits.com/encrypt/demo_text.asp 因此,如果我使用文本\“ Test \”和密钥\“ test \”,它将提供base64编码的字符串。我需要一个PHP示例,使用键“ test”将此编码后的字符串转换回文本“ Test”。     
已邀请:
它取决于它使用的密码,只要您知道应该易于解密的密码和密钥,就看看mcrypt。     
如果您知道加密使用的密码和方式,则功能“ 0”可以对其进行解密。 http://uk3.php.net/manual/zh/function.mcrypt-decrypt.php     
这就是我最终解决的方法: 期望: 密钥是已知的 IV是已知的(在我的情况下,编码数据的前32个字符) 已知加密文本 在我的特殊情况下,所有接收到的数据都进行了十六进制编码。 这意味着IV和加密的文本。
function decrypt($sString, $sIv, $sKey, $iCipherAlg) {       
   $sDecrypted = mcrypt_decrypt($iCipherAlg, $sKey, $sString, MCRYPT_MODE_CBC, $sIv);
    return trim($sDecrypted);
}

function hex2bin($sData) {
    $iLen = strlen($sData);
    $sNewData = \'\';
    for($iCount=0;$iCount<$iLen;$iCount+=2) {
        $sNewData .= pack(\"C\",hexdec(substr($sData,$iCount,2)));
    }
    return $sNewData;
} 

$sKey = \'this is my key\';
// first 32 chars are IV
$sIv = hex2bin(substr($sEncodedData, 0, 32));
$sEncodedData = substr($sEncodedData, 32);
$sEncodedRaw = hex2bin($sEncodedData);
$sDecrypted = decrypt($sEncodedRaw, $sIv, $sKey, MCRYPT_RIJNDAEL_128);
相应的加密方式如下:
$sIv = mcrypt_create_iv(mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND);
$sKey = \'this is my key\';
$sContent = \'a lot of content\';
$sEncrypted = bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $sKey, $sContent, MCRYPT_MODE_CBC, $sIv));
$sFullEncodedText = bin2hex($sIv) . $sEncrypted;
    

要回复问题请先登录注册