-
-
Save tjkendev/f006f6630686a36753e765c5908541ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
K="ABCDEFGHIJKLMNOPQRSTUVWXYZ{}" | |
index=K.index | |
lk = len(K) | |
k="????????????" | |
key_l = len(k) | |
p="SECCON{???????????????????????????????????}" | |
c="LMIG}RPEDOEEWKJIQIWKJWMNDTSR}TFVUFWYOCBAJBQ" | |
p_md5="f528a6ab914c1ecf856a1d93103948fe" | |
l = len(c) | |
# 復号化 | |
for i in xrange(l): | |
if p[i]=="?": continue | |
v = K[(index(c[i]) - index(p[i]) + lk) % lk] | |
ks[i%key_l] = v | |
print ks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
K="ABCDEFGHIJKLMNOPQRSTUVWXYZ{}" | |
index=K.index | |
lk = len(K) | |
k="????????????" | |
key_l = len(k) | |
p="SECCON{???????????????????????????????????}" | |
c="LMIG}RPEDOEEWKJIQIWKJWMNDTSR}TFVUFWYOCBAJBQ" | |
p_md5="f528a6ab914c1ecf856a1d93103948fe" | |
l = len(c) | |
ks = list("VIGENERE????") | |
import itertools, md5 | |
for el in itertools.product(K, repeat=4): | |
ks[-4:] = el | |
p_tmp = list(p) | |
for i in xrange(l): | |
p_tmp[i] = K[(index(c[i]) - index(ks[i%key_l]) + lk) % lk] | |
digest = md5.new("".join(p_tmp)).hexdigest() | |
print digest | |
if digest == p_md5: | |
print "".join(p_tmp) | |
exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment