All pastes #74797 Raw Edit

Stuff

public python v1 · immutable
#74797 ·published 2006-06-29 13:48 UTC
rendered paste body
#!/usr/bin/pythonimport sys, re, osfrom optparse import OptionParserparser = OptionParser()(option, value) = parser.parse_args()if len(value) != 0 and os.path.isfile(value[0]):        file = value[0]else:        print 'Must specify valid filename!'        raise sys.exit(127)f = open (value[0])content = f.read()string = ''chunklen = 16addString = ''#re.Ldef chunkString(string, chunkSize):        nList = []        for privChunk in range(0, len(string), chunkSize):                nList.append(string[privChunk:privChunk + chunkSize])        return nListfor chunk in range(0, len(content), chunklen):        chunkStr = content[chunk:chunk + chunklen]        for splitChunk in range (0, len(chunkStr), 4):                hexStr = chunkStr[splitChunk:splitChunk + 4]                for tile in range (0, 4 - len(hexStr)):                        string += '   '                sys.stdout.write(' '.join(chunkString(hexStr.encode('hex'),2)) + string + ' | ')        sys.stdout.write(re.sub('[\s]', '.', chunkStr) + '\n')        string = ''f.close()