其他分享
首页 > 其他分享> > [TWCTF] superexpress

[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

  

标签:encrypted,inv,superexpress,TWCTF,key,print,ord,251
来源: https://www.cnblogs.com/p201721410013/p/12856584.html