MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / RC4_encrypt

Function RC4_encrypt

pager_lib/smb/utils/rc4.py:2–22  ·  view source on GitHub ↗
(key, data)

Source from the content-addressed store, hash-verified

1
2def RC4_encrypt(key, data):
3 S = list(range(256))
4 j = 0
5
6 key_len = len(key)
7 for i in list(range(256)):
8 j = (j + S[i] + key[i % key_len]) % 256
9 S[i], S[j] = S[j], S[i]
10
11 j = 0
12 y = 0
13 out = []
14
15 for char in data:
16 j = (j + 1) % 256
17 y = (y + S[j]) % 256
18 S[j], S[y] = S[y], S[j]
19
20 out.append(char ^ S[(S[j] + S[y]) % 256])
21
22 return bytes(out)

Callers 1

Calls 2

rangeFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected