byte[] ctxbytes = System.Text.Encoding.UTF8.GetBytes(ctx);
byte[] keybytes = System.Text.Encoding.UTF8.GetBytes(key);
int ctxLen = ctxbytes.Length;
int keyLen = keybytes.Length;
byte[] tempbytes = new byte[ctxLen];
int index = 0;
for (int i = 0; i < ctxbytes.Length; i++)
{
if (index == keyLen)
{
index = 0;
}
tempbytes[i] = (byte)(ctxbytes[i] ^ keybytes[index]);
index++;
}
return System.Text.Encoding.UTF8.GetString(tempbytes, 0, tempbytes.Length);
$temp = "";
$ctxLen = strlen($ctx);
$keyLen = strlen($key);
$index = 0;
for ($i=0;$i<$ctxLen;$i++) {
if ($index == $keyLen) {
$index = 0;
}
$temp .= $ctx[$i] ^ $key[$index];
$index++;
}
return $temp;
标签:index,C#,加解密,int,Length,tempbytes,byte,PHP,keyLen From: https://blog.51cto.com/kenkao/5991656