gpt4 book ai didi

powershell - 将XOR操作应用于字节数组?

转载 作者:行者123 更新时间:2023-12-03 12:21:06 25 4
gpt4 key购买 nike

我有一个字节数组:

$bytes = [System.IO.File]::ReadAllBytes($myFile)

我想对此数组中的每个字节执行XOR操作,如下所示(在python中)
bytes[i] ^= 0x6A  // python-style

我试过了
for($i=0; $i -lt $bytes.count ; $i++)
{
$bytes[$i] = $bytes[$i] -xor 0x6A
}

但是不起作用:$ bytes [$ i]的值为0x00。

如何在Powershell中完成此操作?

谢谢 !

最佳答案

-xor是返回True或False的逻辑运算符。也许您想通过-bxor使用按位异或运算?

for($i=0; $i -lt $bytes.count ; $i++)
{
$bytes[$i] = $bytes[$i] -bxor 0x6A
}

关于powershell - 将XOR操作应用于字节数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23681705/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com