Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from subprocess import call
- from pymd5 import md5, padding
- import os
- def checkValid(name):
- chars = set('()')
- with open(name, 'r') as f:
- blob = f.readlines()[2:]
- for s in blob:
- if any((c in chars) for c in s):
- return False
- return True
- def addPad(name):
- bytes = os.stat(name).st_size
- with open(name, 'a') as f:
- f.write(padding(8*bytes))
- def concatPad(name1,name2,name3):
- bytes1 = os.stat(name1).st_size
- f3 = open(name3, 'w')
- f2 = open(name2, 'r')
- f1 = open(name1, 'r')
- prefix = f1.read()
- blob = f2.read()
- prefix = prefix+padding(8*bytes1)
- f3.write(prefix+blob)
- f1.close
- f2.close
- f3.close
- for i in range(1,7):
- if i==1:
- while True:
- call(["./fastcoll", "-p", "324prefix","-o" , "col1_0", "col1_1"])
- if (checkValid("col1_0") and checkValid("col1_1")):
- break
- continue
- parent = "col"+str(i-1)+"_0"
- init = md5(open(parent, "rb").read()).hexdigest()
- while True:
- call(["./fastcoll", "-i", init,"-o" , "cola", "colb"])
- if (checkValid("cola") and checkValid("colb")):
- break
- skip = pow(2,i-1)
- idx = 0
- for j in range(0,skip):
- parent = "col"+str(i-1)+"_"+str(j)
- left = "col"+str(i)+"_"+str(idx)
- right = "col"+str(i)+"_"+str(idx+1)
- concatPad(parent,"cola", left)
- concatPad(parent,"colb", right)
- idx = idx+2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement