[Solved] Convert c++ function to PHP?


You can use almost the same syntax in PHP as your C++ function does:

function encryptDecrypt($toEncrypt)
{
    $key= array( '1', '2', '3', '4', '5', '6', '7', '8', '9' );
    $key_len = count($key);
    $output = $toEncrypt;
    for ($i = 0; $i < strlen($toEncrypt); $i++)
    {
       $output[$i] = $toEncrypt[$i] ^ $key[$i % $key_len];
    }

    return $output;
}

Online demo for C++ function: https://ideone.com/g9cpHJ

Online demo for PHP function: https://ideone.com/3prgd0

4

solved Convert c++ function to PHP?