RC4算法的原理和应用有哪些特点?

摘要:其实不是rc4 ,我就是一个脑瘫扭头就忘,其实是没用心记罢了,所以写一个博客加深印象。 当然这掩盖不了我是一个傻逼的事实。 Source Generated with Decompyle++ File:
其实不是rc4 ,我就是一个脑瘫扭头就忘,其实是没用心记罢了,所以写一个博客加深印象。 当然这掩盖不了我是一个傻逼的事实。 Source Generated with Decompyle++ File: pyAndR.pyc (Python 3.6) def init_S(): for i in range(256): S.append(i) def init_T(): global Key Key = 'abcdefg' keylen = len(Key) for i in range(256): tmp = Key[i % keylen] T.append(tmp) def swap_S(): j = 0 for i in range(256): j = (j + S[i] + ord(T[i])) % 256 tmp = S[i] S[i] = S[j] S[j] = tmp def Get_KeyStream(): txtlen = len(text) (j, t) = (0, 0) for i in range(txtlen): i = i % 256 j = (j + S[i]) % 256 tmp = S[i] S[i] = S[j] S[j] = tmp t = (S[i] + S[j]) % 256 KeyStream.append(S[t]) def Get_code(): res = [] for i in range(len(text)): res.append(ord(text[i]) ^ KeyStream[i]) return res if name == 'main': T = [] S = [] Key = [] PlainText = '' CryptoText = '' KeyStream = [] text = input('please input you flag:\n') if not text: print('bad') exit() init_S() init_T() swap_S() Get_KeyStream() res = Get_code() print(res) for i, ele in enumerate(res): if not ele == [ 84, 91, 254, 48, 129, 210, 135, 132, 112, 234, 208, 15, 213, 39, 108, 253, 86, 118, 248][i]: print('bad') exit() print('good') pyc转py。可以看我之前的博客 ✅ 第1步:照抄 RC4 初始化 S = [] T = [] Key = 'abcdefg' KeyStream = [] ✅ 第2步:跑一遍 RC4(不用改) init_S() init_T() swap_S() ✅ 第3步:生成 KeyStream 注意长度: text = "A" * 19 # 因为密文长度是19 👉 只是为了生成 KeyStream(内容无所谓) Get_KeyStream() ✅ 第4步:逆运算 cipher = [84,91,254,...] flag = [] for i in range(len(cipher)): flag.append(cipher[i] ^ KeyStream[i]) ✅ 第5步:转字符 print(''.join(map(chr, flag))) 懒得写了,凑活看吧,回头再更新 4.13 其实rc4加密最主要还是^。所以要识别的话只需要看有没有256之类的就行、