Blackthorn

Binary data test

Nov 28th, 2022 (edited)
1,649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Print some binary data using powershell function Format-Hex
  2. [System.Convert]::FromHexString("C0FFEE") | Format-Hex
  3.  
  4. #   Label: Byte (System.Byte) <6DDAB385>
  5. #
  6. #          Offset Bytes                                           Ascii
  7. #                 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
  8. #          ------ ----------------------------------------------- -----
  9. #0000000000000000 C0 FF EE  
  10.  
  11. #
  12. # Print some binary data using xxd (powershell won't do this correctly)
  13. #
  14. [System.Convert]::FromHexString("C0FFEE") | xxd      
  15. # 00000000: 3139 320a 3235 350a 3233 380a            192.255.238.
  16.  
  17. # Write binary data to file using Set-Content
  18. [System.Convert]::FromHexString("C0FFEE") | Set-Content -AsByteStream ./test.bin
  19.  
  20. # Data is stored correctly and can be read by xxd
  21. xxd ./test.bin
  22. # 00000000: c0ff ee
  23.  
  24. # Start-Process RedirectStandardInput also doesn't work as I would expect.
  25. Start-Process xxd -RedirectStandardInput ./test.bin
  26. # 00000000: efbf bdef bfbd 0a                        .......
Advertisement
Add Comment
Please, Sign In to add comment