2012-04-22 20:54:29 +00:00
|
|
|
package require binary
|
|
|
|
|
2013-11-26 21:47:58 +00:00
|
|
|
proc hexdump data {
|
|
|
|
set dump ""
|
|
|
|
set n 0
|
|
|
|
while {$n < [string bytelength $data]} {
|
|
|
|
set bytes [string byterange $data $n $($n+15)]
|
|
|
|
binary scan $bytes H* hex
|
|
|
|
set hex [regexp -all -inline .. $hex]
|
|
|
|
regsub -all -- {[^a-z]} $bytes . ascii
|
|
|
|
append dump [format "%04X: %-48s %-16s\n" $n $hex $ascii]
|
|
|
|
incr n 16
|
|
|
|
}
|
|
|
|
puts $dump
|
2012-04-22 20:54:29 +00:00
|
|
|
}
|
|
|
|
|