Skip to content

Instantly share code, notes, and snippets.

@breezhang
Created February 20, 2012 12:14
Show Gist options
  • Save breezhang/1868969 to your computer and use it in GitHub Desktop.
Save breezhang/1868969 to your computer and use it in GitHub Desktop.
from twitters :)
function Get-HexDump($path,$width=10, $bytes=-1)
{
$OFS=""
Get-Content -Encoding byte $path -ReadCount $width `
-totalcount $bytes | Foreach-Object {
$byte = $_
$hex = $byte | Foreach-Object {
" " + ("{0:x}" -f $_).PadLeft(2,"0")}
$char = $byte | Foreach-Object {
if ([char]::IsLetterOrDigit($_))
{ [char] $_ } else { "." }}
"$hex $char"
}
}
#function Get-xxx {
# Write-Host "Get-xxxx:"
#}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment