Skip to content

茶里茶气

简单的 TEA(Tiny Encryption Algorithm)加密算法

只需要逆推一下过程,然后把字符串拼接在一起转成字符即可

对于 v2 这个变量,先进行正推得到最终值,再倒退进行解密(数量级不大,使用乘法和加法都可以)

注意每一步都要取模

python
v2 = 0
delta = 462861781278454071588539315363
v3 = 489552116384728571199414424951
v4 = 469728069391226765421086670817
v5 = 564098252372959621721124077407
v6 = 335640247620454039831329381071
l  = 199
p  = 446302455051275584229157195942211
v0 = 190997821330413928409069858571234
v1 = 137340509740671759939138452113480

for i in range( 32 ):
    v2 += delta ; v2 %= p

for i in range(32):
    v2 -= delta ; v2 %= p
    v0 -= (v1+v2) ^ ( 8*v1 + v5 ) ^ ( (v1>>7) + v6 ) ; v0 %= p
    v1 -= (v0+v2) ^ ( 8*v0 + v3 ) ^ ( (v0>>7) + v4 ) ; v1 %= p

a = hex((v0<<((l//2))) + v1)[2:]

flag = ""
for i in range(0,len(a),2):
    flag += chr(int(a[i]+a[i+1],16))

print(flag)
# flag{f14gg9_te2_1i_7ea_7}