Changeset 9 for bin/bletchley-analyze
- Timestamp:
- 10/19/12 11:11:55 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
bin/bletchley-analyze
r1 r9 66 66 67 67 def printColoredHexDump(blobs, group_size=8): 68 chunk_size = 6468 line_size = 64 69 69 group_size *= 2 # two hex digits per byte 70 70 print(group_size) 71 71 hex_blobs = map(binascii.b2a_hex, blobs) 72 72 color_map = buffertools.blockWiseColorMap(group_size, hex_blobs) … … 74 74 for k in range(0,len(hex_blobs)): 75 75 hex = hex_blobs[k] 76 line = ''77 76 78 for i in range(0,len(hex), chunk_size):79 line += '%.8X: ' % i77 for i in range(0,len(hex),line_size): 78 line = '%.8X: ' % i 80 79 81 if len(hex ) < chunk_size:82 hex += ( chunk_size-len(hex))*' '80 if len(hex[i:]) < line_size: 81 hex += (line_size-len(hex[i:]))*' ' 83 82 84 for j in range(0,len(hex),group_size): 85 group = hex[j:j+group_size] 86 line += terminalHighlightedString(color_map.get(group, None), group) + ' ' 83 for j in range(0,line_size,group_size): 84 group = hex[i+j:i+j+group_size] 85 line += terminalHighlightedString(color_map.get(group, None), group) + ' ' 86 87 line += '| ' 88 line += repr(blobs[k][i/2:(i+line_size)/2]) 87 89 88 line += '| ' 89 line += repr(blobs[k][i/2:(i+chunk_size)/2]) 90 line += '\n' 91 92 print(line) 90 print(line) 91 print('') 93 92 94 93
Note: See TracChangeset
for help on using the changeset viewer.