Created
November 21, 2019 13:40
-
-
Save maravedi/fe22ccf1c097d259fd2102d0a4049110 to your computer and use it in GitHub Desktop.
Separator for an HTTP Request with combined ASCII and Hex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param( | |
[String]$Raw, | |
$ASCIIColor = 'White', | |
$HexColor = 'Blue' | |
) | |
$Original = $Host.UI.RawUI.ForegroundColor | |
Write-Host "=======================" | |
$Host.UI.RawUI.ForegroundColor = $ASCIIColor | |
Write-Host "$($ASCIIColor): ASCII" | |
$Host.UI.RawUI.ForegroundColor = $HexColor | |
Write-Host "$($HexColor): Hex" | |
$Host.ui.RawUI.ForegroundColor = $Original | |
Write-Host "=======================`n" | |
$Cleaned = ($Raw -Replace '\^M','').Trim() | |
$TextArray = $Cleaned -Split ' ' | |
$ASCII = @() | |
$Hex = @() | |
Foreach($Item in $TextArray){ | |
If($Item -like '0x*'){ | |
$Hex += "$([char][byte]$Item)" | |
} | |
Else{ | |
$ASCII += "$($Item)" | |
} | |
} | |
$Host.ui.RawUI.ForegroundColor = $ASCIIColor | |
Write-Host "$($ASCII -Split ' ')" | |
$Host.ui.RawUI.ForegroundColor = $HexColor | |
Write-Host "$($Hex -Join '')" | |
$Host.ui.RawUI.ForegroundColor = $Original |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment