1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| import base64
def gen(key): s = list(range(256)) j = 0 for i in range(256): j = (j + s[i] + ord(key[i % len(key)])) % 256 tmp = s[i] s[i] = s[j] s[j] = tmp i = j = 0 data = [] for _ in range(50): i = (i + 1) % 256 j = (j + s[i]) % 256 tmp = s[i] s[i] = s[j] s[j] = tmp data.append(s[(s[i] + s[j]) % 256]) return data
def encrypt(text, key): result = '' for c, k in zip(text, gen(key)): result += chr(ord(c) ^ k) result = base64.b64encode(result.encode()).decode() return result
key = 'As_we_do_as_you_know' print(gen(key)) key2 = [213, 242, 54, 127, 156, 227, 172, 100, 212, 1, 130, 92, 20, 189, 115, 12, 15, 228, 186, 225, 227, 75, 200, 119, 171, 11, 152, 15, 89, 160, 116, 157, 194, 226, 72, 147, 65, 74, 92, 21, 136, 193, 152, 94, 17, 178, 205, 195, 87, 145] enc = 'wr3ClVcSw7nCmMOcHcKgacOtMkvDjxZ6asKWw4nChMK8IsK7KMOOasOrdgbDlx3DqcKqwr0hw701Ly57w63CtcOl' print(list(base64.b64decode(enc.encode()).decode())) enc2 = ['½', '\x95', 'W', '\x12', 'ù', '\x98', 'Ü', '\x1d', '\xa0', 'i', 'í', '2', 'K', 'Ï', '\x16', 'z', 'j', '\x96', 'É', '\x84', '¼', '"', '»', '(', 'Î', 'j', 'ë', 'v', '\x06', '×', '\x1d', 'é', 'ª', '½', '!', 'ý', '5', '/', '.', '{', 'í', 'µ', 'å'] for c, k in zip(enc2, key2): print(chr(ord(c)^k),end='')
|