In my previous post I showed you a couple of wrapper functions I made to handle binary to string conversion (and vice versa). Building on one of these I thought it would be fun to try to make a simple file hex viewer, similar to how popular hex editors work (without the editing part of course).
The function opens a filestream and uses a binary reader object to read the file, then pipes the result to my wrapper function called Invoke-CryptBinaryToString that shows a string representation of the file in hex as well as in ASCII. Optionally you can also add address fields using the ShowAddress parameter.
This means that you need to have my code from the previous post loaded in memory to be able to use this one.
The function also lets you choose where to start and how many bytes it should read, in case you only want to look at particular sections of the file.
Hope you find this one interesting. Catch you on the next one!
UPDATE! As Kirk mentions in his comment down below, this functionality is in fact natively supported in PowerShell version 5! So no need for my function at all if you are using v5. 🙂