将C#代码段转换为PHP

时间:2019-02-24 15:40:36

标签: c# php transform translate

有人可以帮助我将XOR解密转换为PHP吗?

public static string DecryptKey(string key)
{
    byte[] b = Convert.FromBase64String(key);
    char[] arr = new char[b.Length];

    for (int ii = 0; ii < b.Length; ii++)
    {
        arr[ii] = (char)(b[ii] ^ 14);
    }

    return new string(arr);

}

1 个答案:

答案 0 :(得分:1)

完成它。谢谢您的帮助

public function DecryptKey($InputString) {
  $InputString = base64_decode($string);
    $retString='';
    for ($j = 0; $j < strlen($InputString); $j++) {
        $retString .= chr(ord(substr($InputString, $j, 1)) ^ 14);
    }
    return $retString;

}