0
我有mysite緩存文件,我想從遠程獲取所有這些文件。我在我的網站上寫了一個小應用程序,用查詢字符串回顯加密的文本。從遠程獲取文本確定,但文本有一些不好的字符或東西是錯誤的。 我的遠程代碼:請求url並獲取加密文本
$req = file_get_contents($website.'Cache.php?cacheid='.$filename.'&action=getContent');
$req = trim($req);
$req = str_replace (array("\r\n", "\n", "\r"), '', $req);
$decryptedText = decrypt(trim($req),'mypass') ;
array_push($fileNameTexts,'<div style="color:red;">'.$filename.'</div><div>'.$decryptedText.'</div>');
}
$template->data['decryptedCaches'] = $fileNameTexts;
}
function decrypt($encrypted, $password, $salt='mysalt') {
**file_put_contents(DIR_SYSTEM.'test'.'.txt',$encrypted);**
$key = hash('SHA256', $salt . $password, true);
$iv = base64_decode(substr($encrypted, 0, 22) . '==');
$encrypted = substr($encrypted, 22);
$decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, base64_decode($encrypted), MCRYPT_MODE_CBC, $iv), "\0\4");
$hash = substr($decrypted, -32);
$decrypted = substr($decrypted, 0, -32);
if (md5($decrypted) != $hash) return false;
return $decrypted;
}
file_put_contents保存正確的數據,但不能退貨解密的真實數據。
當我嘗試
$decryptedText = decrypt(trim('kjsfkdsjflkdsflksdjfsl'),'mypass') ;
它運行正確。我嘗試修剪和str_replace一些字符,但它does not work.Has返回數據請求任何壞字符?什麼是問題?