Question:
Need help to convert all hex characters contained in a text file to string or ASCII. Hex characters appear in a standard format of
1 2 3 |
user1 domain1 7374726f6e6770617373776f7264403130 user2 domain2 7374726f6e6770617373776f7264403120 |
After conversion it should show as
1 2 |
user1 domain1 strongpassword@10 |
the text file contains the multiple passwords, all arranged in a row
Answer:
1 2 3 4 5 6 7 8 9 10 11 12 |
Get-Content file.txt | Foreach-Object{ $user,$domain,$pass = $_.Split() $pass = for($i=0; $i -lt $pass.length; $i+=2) { [char][int]::Parse($pass.substring($i,2),'HexNumber') } $user,$domain,(-join $pass) -join ' ' } |