Skip to content

Instantly share code, notes, and snippets.

@calebrob6
Created April 2, 2013 03:28
Show Gist options
  • Save calebrob6/5289695 to your computer and use it in GitHub Desktop.
Save calebrob6/5289695 to your computer and use it in GitHub Desktop.
xkcd challenge
import skein,itertools
inputNum = 26
target = "5b4da95f5fa08280fc9879df44f418c8f9f12ba424b7757de02bbdfbae0d4c4fdf9317c80cc5fe04c6429073466cf29706b8c25999ddd2f6540d4475cc977b87f4757be023f19b8f4035d7722886b78869826de916a79cf9c94cc79cd4347d24b567aa3e2390a573a373a48a5e676640c79cc70197e1c5e7f902fb53ca1858b6"
targetBin = '0b'+(bin(int(target, 16))[2:]).zfill(1024)
def doWork(a):
return '0b'+(bin(int(skein.skein1024(bytes(a,'utf-8')).hexdigest(), 16))[2:]).zfill(1024)
def binDifference(a,b):
count=0
#print(a)
#print(b)
#print("---------------")
for i in range(len(a)):
if a[i] != b[i]:
count+=1
return count
out = str(binDifference(targetBin,doWork('26')))
i=0
alphabet = "abcdefghijklmnopqrstuvwxyz"
'''
for x in itertools.combinations_with_replacement(alphabet, r=4):
#print(str(''.join(x)))
out = binDifference(targetBin,doWork(''.join(x)))
#print(str(''.join(x))+" -- "+str(out))
if out < 423:
print("Found: "+str(i))
i+=1
if i>1000000000:
break
if i%1000==0:
print(i)
'''
for x in range(1000000000):
#print(str(''.join(x)))
out = binDifference(targetBin,doWork(str(x)))
#print(str(''.join(x))+" -- "+str(out))
if out < 423:
print("Found: "+str(i))
if x%1000000==0:
print(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment