Changeset 9 for bin


Ignore:
Timestamp:
10/19/12 11:11:55 (12 years ago)
Author:
tmorgan
Message:

fixed problems with hexdump

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bin/bletchley-analyze

    r1 r9  
    6666
    6767def printColoredHexDump(blobs, group_size=8):   
    68     chunk_size = 64
     68    line_size = 64
    6969    group_size *= 2 # two hex digits per byte
    70 
     70    print(group_size)
    7171    hex_blobs = map(binascii.b2a_hex, blobs)
    7272    color_map = buffertools.blockWiseColorMap(group_size, hex_blobs)
     
    7474    for k in range(0,len(hex_blobs)):
    7575        hex = hex_blobs[k]
    76         line = ''
    7776       
    78         for i in range(0,len(hex),chunk_size):
    79             line += '%.8X: ' % i
     77        for i in range(0,len(hex),line_size):
     78            line = '%.8X: ' % i
    8079
    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:]))*' '
    8382
    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])
    8789       
    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('')
    9392
    9493
Note: See TracChangeset for help on using the changeset viewer.