mysite에 캐시 파일이 있고 원격에서 모든 파일을 가져오고 싶습니다. 내 사이트에 작은 응용 프로그램을 작성,이 에코 암호 문자열로 암호화 된 텍스트. 원격 ok에서 텍스트를 가져 오지만 텍스트에는 잘못된 문자가 있거나 일 부적으로 잘못되었습니다. 내 원격 코드 :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를 시도하지만 작동하지 않습니다. 요청한 데이터 중 임의의 잘못된 문자가 반환 되었습니까? 문제가 무엇입니까?