Last active
August 28, 2019 01:09
-
-
Save guesslin/ee38abfac7284843f04c02d1a0c9763f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
packet main | |
import "fmt" | |
func HexPacket(raw []byte) { | |
idx := 0 | |
for ; idx < len(raw)-16; idx += 16 { | |
fmt.Printf("%04X: ", idx) | |
for i := 0; i < 16; i++ { | |
fmt.Printf("%02X ", raw[idx+i]) | |
if (i+1)%4 == 0 { | |
fmt.Printf(" ") | |
} | |
} | |
fmt.Printf("\n") | |
} | |
if idx < len(raw) { | |
fmt.Printf("%04X: ", idx) | |
for i := 0; i < len(raw)-idx; i++ { | |
fmt.Printf("%02X ", raw[idx+i]) | |
if (i+1)%4 == 0 { | |
fmt.Printf(" ") | |
} | |
} | |
fmt.Printf("\n") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment