[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

  

posted @ 2020-05-09 12:44  S4tan  阅读(482)  评论(0编辑  收藏  举报