小编Jer*_*emy的帖子

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

我有一个字节数组:

$bytes = [System.IO.File]::ReadAllBytes($myFile)
Run Code Online (Sandbox Code Playgroud)

我想对这个数组中的每个字节执行一个XOR运算,就像这样(在python中)

bytes[i] ^= 0x6A  // python-style
Run Code Online (Sandbox Code Playgroud)

我试过了

for($i=0; $i -lt $bytes.count ; $i++)
{
    $bytes[$i] = $bytes[$i] -xor 0x6A
}
Run Code Online (Sandbox Code Playgroud)

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

怎么能在powershell中完成?

谢谢 !

powershell

5
推荐指数
1
解决办法
8441
查看次数

删除与数组匹配的行

我有一个完整的行文件,我想删除任何与数组中的字符串匹配的行,使用PowerShell:

$stringsiDoNotWant = @("admin", "student")

$content = gc file.txt
Run Code Online (Sandbox Code Playgroud)

$content = $content -notcontains $StringsiDoNotWant
Run Code Online (Sandbox Code Playgroud)

不起作用:我在变量中仍然有"admin"和"student" $content.

arrays powershell scripting

1
推荐指数
1
解决办法
810
查看次数

标签 统计

powershell ×2

arrays ×1

scripting ×1