Bazı javascript'i bir okul projesi için PHP'ye dönüştürmem gerekiyor, fakat eksik olan bir şey var gibi görünüyor, çünkü aynı kod birdenbire erken çıkıyor. Javascript özyinesini PHP'ye dönüştürmeye çalışın (kolay)
for(var j=0; j<asciiArray.length;j++) {
passwordFound[location] = String.fromCharCode(asciiArray[j]);
console.log(passwordFound.join(""));
if (password === passwordFound.join("")) {
document.getElementById("password").innerHTML = 'Password: ' + passwordFound.join("");
return true;
}
else if (location < 2) {
var newlocation = location+1;
if (characterDecryptFunction(newlocation,asciiArray,passwordFound,password)) return true;
}
}
Bu
PHP'dir:function characterDecryptFunction($index, $maxIndex, $asciiArray, $passwordFound, $password) {
for ($j=0;$j<count($asciiArray);++$j)
{
$passwordFound[$index] = chr($asciiArray[$j]);
echo "<br>" . implode("", $passwordFound);
if ($password === implode("",$passwordFound)) {
echo "<br>Password is:" . implode($passwordFound);
return true;
}
elseif ($index < $maxIndex)
{
$index = $index+1;
if (characterDecryptFunction($index,$maxIndex, $asciiArray, $passwordFound, $password) == true) return true;
}
}
return false;}
DÜZENLEME:
JavaScript gibi adlandırılır:
function decryptFunction() {
var x,y,z,password,asciiArray=[],passwordFound=[];
password="abc";
asciiArray.push(0);
asciiArray.push(32);
for (x=48;x!=58;x++) {
asciiArray.push(x);
}
for (y=97;y!=123;y++) {
asciiArray.push(y);
}
for (z=65;z!=91;z++) {
asciiArray.push(z);
}
characterDecryptFunction(0, asciiArray, passwordFound,password);}
Ve PHP:
function decryptFunction() {
$password = $_POST["password"];
$asciiArray=array();
$passwordFound=array();
for($x=48;$x!=58;$x++)
{
array_push($asciiArray, $x);
}
for($x=97;$x!=123;$x++)
{
array_push($asciiArray, $x);
}
for($x=65;$x!=91;$x++)
{
array_push($asciiArray, $x);
}
for ($x=0;$x<count($asciiArray);$x++)
{
echo $asciiArray[$x];
}
echo $password . "<br>";
characterDecryptFunction(0, 2, $asciiArray, $passwordFound, $password); }
Erken diyorsunuz, nerede kastediyorsunuz? Ayrıca, PHP sürümünde ekstra bir geri dönüş olduğunu unutmayın. Bu bir hata mı, bilmiyorum, sadece bir fark. – Lewis
Orijinal kod tüm seçeneklerden geçerken, bu aniden 01Z'de durur. Bu sadece temel bir çatlama algoritmasıdır, ancak 01x ila 02x arasında görünmüyor. Fazladan geri dönüş orijinalde de ama onu yayınlamayı unuttum. – user2445723
Ve 01x' ve '02x' ile ne demek istiyorsun? – stjepano