[TWCTF] superexpress

#problem.py
import sys
key = '****CENSORED***************'
flag = 'TWCTF{*******CENSORED********}'

if len(key) % 2 == 1:
    print("Key Length Error")
    sys.exit(1)

n = len(key) / 2
encrypted = ''
for c in flag:
    c = ord(c)
    for a, b in zip(key[0:n], key[n:2*n]):
        c = (ord(a) * c + ord(b)) % 251
    encrypted += '%02x' % c

print encrypted

  

这道题目和星盟训练赛里最后一道crypto一样

都是化简同余式

str1 = '805eed80cbbccb94c36413275780ec94a857dfec8da8ca94a8c313a8ccf9'.decode('hex')
print str1
import gmpy2
inv = gmpy2.invert(156,251)
print inv
str2 = ''
for i in str1:
	str2 += chr(((ord(i)-76)*int(inv))%251)
print str2

  

上一篇:Effective C++ 条款26 尽可能延后变量定义式的出现


下一篇:Mysql:Changes in MySQL 5.6.30 (2016-04-11, General Availability):--ssl-mode: