Created
July 18, 2020 19:19
-
-
Save sysopfb/19aa8e0bdecde60662b7adecdc72b11f to your computer and use it in GitHub Desktop.
RC4 algorithm with SBOX extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def decode_data(data, key, sz): | |
| S = list(range(sz)) | |
| S = [x&0xff for x in S] | |
| j = 0 | |
| out = [] | |
| for i in range(sz): | |
| j = (j + S[i] + ord( key[i % len(key)] )) % sz | |
| S[i] , S[j] = S[j] , S[i] | |
| i = j = 0 | |
| for char in data: | |
| i = ( i + 1 ) % sz | |
| j = ( j + S[i] ) % sz | |
| S[i] , S[j] = S[j] , S[i] | |
| out.append(chr(ord(char) ˆ S[(S[i] + S[j]) % sz])) | |
| return ''.join(out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment