#!/usr/bin/python import hashlib f="/home/agagag/media/images/dentro2.jpg" s=open(f) source=s.read() m = hashlib.md5() m.update(source) m.update(source) raw=m.digest() dgst_raw=bytearray(raw) print "hexdigest of input file %s : %s " % (f, m.hexdigest(),) print "length in bytes : %d" % m.digest_size # FLDBASE got to be even FLDBASE=8 FLDSIZE_Y=(FLDBASE + 1) FLDSIZE_X=(FLDBASE * 2 + 1) augmentation_string = " .o+=*BOX@%&#/^SE" dgst_size=m.digest_size # create a 2d array and fill it up with dots field = [['.' for x in range(FLDSIZE_X)] for y in range(FLDSIZE_Y)] length=len(augmentation_string)-1 # we start in the center. x = FLDSIZE_X / 2 y = FLDSIZE_Y / 2 field[y][x]='x' print "Initial value of x %d" % x print "Initial value of y %d" % y # process raw key for i in range(0,dgst_size): mybyte= dgst_raw[i] if mybyte > 128: y+=1 x+=1 field[y][x]='>' print 'x', x, if x==0 or y==0: x = max(x, 0) y = max(y, 0) else: if x > FLDSIZE_X-1 or y > FLDSIZE_Y-1: x = min(x, FLDSIZE_X - 1) y = min(y, FLDSIZE_Y - 1) else: if mybyte < 128: x-=1 y-=1 field[y][x]='<' print 'y', y, #print rows for row in field: print "".join(row)