Greetings
Help me to understand. I need to convert names to hex for certain reasons. Suppose the name "Ivan" should look like this c8e2e0ed (used the online encoder http://crypt-online.narod.ru/crypts/text2hex/ )
As for PowerShell, all my attempts to get this value (c8e2e0ed) failed.
Here is all I tried:
PS Z:\> $string = "Иван" PS Z:\> $data = $string | Format-Hex PS Z:\> $data.Bytes 63 63 63 63 PS Z:\> [System.Text.Encoding]::Unicode.GetBytes('Иван') 24 4 50 4 48 4 61 4 PS Z:\> [System.Text.Encoding]::UTF8.GetBytes('Иван') 208 152 208 178 208 176 208 189 PS Z:\> $a = "Иван"; PS Z:\> $b = $a.ToCharArray(); PS Z:\> Foreach ($element in $b) {$c = $c + [System.String]::Format("{0:X2}" + "", [System.Convert]::ToUInt32($element)} PS Z:\> $c 41843243043D PS Z:\> function ConvertTo-QdsString {param([string]$String) -join ([Text.Encoding]::Unicode.GetBytes($String) | % { $CheckSum = 0 } { $_; $CheckSum = ($CheckSum + $_) % 256 } { 0; 0; $CheckSum } | % ToString X2) } ConvertTo-QdsString Иван 1804320430043D040000C7