$ByteFile="$PWD/test.txt"
$ByteArray = [io.file]::ReadAllBytes($ByteFile)
echo "=== Original Byte Array ==="
$ByteArray
$Width = $ByteArray.Length
$Position = 0..$Width
$Buf =  0..$Width
$RetBuf = 0..$Width
$HashTab = @{}
$Count = 0
$CountRet = 0
$ScrambledPosition = $Position | Sort-Object {Get-Random}
echo "=== ScrambledPosition Original ==="
$ScrambledPosition
#$ScrambledPosition[0]
foreach($Key in $ScrambledPosition) {
    #$HashTab.add($Key, $ByteArray[$Count])
    #$Key
    echo $Buf[$Count] = $ByteArray[$Key]
    $Count++
    #$buf[$PSItem]# = $ByteArray[$scrambledPosition[$PSItem]]
    #$PSItem
    #$ByteArray[$PSItem]
    #$tem
    #Write-Host "$ScrambledPosition[$Count] : $ByteArray[$PSItem]"
    ##$ScrambledPosition[$Count]
    #[System.BitConverter]::ToString($PSItem)
}

Write-Output "=== Buf ==="
$Buf

foreach($Key in $Buf) {
    $PositionRet = $ScrambledPosition[$CountRet]
    #echo "$positionRet = $ScrambledPosition[$CountRet]"
    #$ScrambledPosition[$Key]
    #$ScrambledPosition[$CountRet]
    echo 'Buf[i]:' $Buf[$PositionRet] 'i: ' $positionret
    #$RetBuf[$CountRet]
    #$Buf[$PositionRet]
    $CountRet++
    #$RetBuf[]
}


#$Buf # Scrambled bytes
#$Position # array 0..$Width
#$ByteArray # unscrambled bytes
#$ScrambledPosition # positions of scramble
#$HashTabRand = $HashTab | Sort-Object {Get-Random}
#$HashTab
#Write-Output "=== ScrambledPosition ==="
#$ScrambledPosition
Write-Output "=== ByteArray ==="
$ByteArray
#Write-Output "=== Buf ==="
#$Buf
Write-Output "=== RetBuf ==="
$RetBuf