Skip to content

Instantly share code, notes, and snippets.

@gravejester
Created February 8, 2016 15:22
Show Gist options
  • Save gravejester/2a70db986866993edc08 to your computer and use it in GitHub Desktop.
Save gravejester/2a70db986866993edc08 to your computer and use it in GitHub Desktop.
function Invoke-FixedXOR {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0)]
[byte[]] $ByteArrayOne,
[Parameter(Mandatory = $true, Position = 1)]
[byte[]] $ByteArrayTwo
)
$combinedBytes = New-Object System.Collections.ArrayList
if ($ByteArrayOne.Length -eq $ByteArrayTwo.Length) {
for ($index = 0; $index -lt $ByteArrayOne.Length; $index++) {
[void]$combinedBytes.Add(($ByteArrayOne[$index] -bxor $ByteArrayTwo[$index]))
}
Write-Output $combinedBytes
}
else {
Write-Warning 'Different length!'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment