/bytes-to-hex-and-back

Powershell functions that convert bytes to hex and hex to bytes. Powershell functions that also convert ascii to hex and hex to ascii

Primary LanguagePowerShellGNU General Public License v3.0GPL-3.0

bytes-to-hex-and-back

Powershell functions that convert bytes to hex and hex to bytes.
Powershell functions that also convert ascii to hex and hex to ascii

Usage:

PS C:\Users\chris\Desktop\Testing> Convert-AsciiToHex "Hello World"
48656C6C6F20576F726C64
PS C:\Users\chris\Desktop\Testing> $bytes = Convert-HexToBytes 48656C6C6F20576F726C64
PS C:\Users\chris\Desktop\Testing> $bytes
72
101
108
108
111
32
87
111
114
108
100

PS C:\Users\chris\Desktop\Testing> Convert-BytesToHEX $bytes
48656c6c6f20576f726c64
PS C:\Users\chris\Desktop\Testing> Convert-HexToAscii 48656c6c6f20576f726c64
Hello World

Get Ascii To Bytes (already built into powershell):

$enc = [system.Text.Encoding]::UTF8
$hw = "Hello World"
$bytes = $enc.GetBytes($hw)

Get Bytes To Ascii (already built into powershell):

$enc = [system.Text.Encoding]::UTF8
$helloworld = $enc.GetString($bytes)
$helloworld
Hello World