Convert c++ function to PHP? -


i convert xor function php. can done? needs work it`s working now...

string encryptdecrypt(string toencrypt) {     char key[9] = { '1', '2', '3', '4', '5', '6', '7', '8', '9' };     string output = toencrypt;     (int = 0; < toencrypt.size(); i++)         output[i] = toencrypt[i] ^ key[i % (sizeof(key) / sizeof(char))];      return output; } 

you can use same syntax in php c++ function does:

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

online demo c++ function: https://ideone.com/g9cphj

online demo php function: https://ideone.com/3prgd0


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -