Hello,
I already have:
$StringToConvert = Read-Host ‘Enter string to convert to hex’
$HexValue = New-Object System.Text.StringBuilder
foreach ($Element in $StringToConvert.ToCharArray()) {
[void]$HexValue.Append(‘{0:x}’ -f [System.Convert]::ToUInt32($Element))
$StringLength++
}
$HexValue = $HexValue.ToString()
$HexValue -split ‘(?<=\G[0-9a-f]{2})(?=.)’ -join ’ ’
But this gives something like 68 61 6c 6c 6f
I’m looking for something to make it in a 0x68, 0x61, 0x6c, 0x6c, 06f
Goal is to use this as part of a bigger hex value:
0x10, 0x02, “hex-value-from-above”, 0x10, 0x03
Then the purpose is to use this “total-hex” as data to be written via socket
But that part I have already.