Skip to content

Commit

Permalink
[WIP] py3 - rc4
Browse files Browse the repository at this point in the history
  • Loading branch information
AlessandroZ committed Apr 9, 2019
1 parent c87d014 commit b056305
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Windows/lazagne/config/crypto/rc4.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Thanks to g2jun for his RC4-Python project
# Code from https://github.com/g2jun/RC4-Python

from lazagne.config.winstructure import char_to_int
from lazagne.config.winstructure import char_to_int, chr_or_byte


class RC4(object):
Expand All @@ -20,10 +20,9 @@ def text_to_bytes(self, text):
return byte_list

def bytes_to_text(self, byte_list):
s = ''
s = b''
for byte in byte_list:
s += chr(byte) # chr should not work with Python 3 (will be fixed)

s += chr_or_byte(byte)
return s

def encrypt(self, data):
Expand All @@ -38,7 +37,7 @@ def crypt(self, plain_bytes, key_bytes):

key_len = len(key_bytes)
plain_len = len(plain_bytes)
S = range(256)
S = list(range(256))

j = 0
for i in range(256):
Expand All @@ -54,5 +53,5 @@ def crypt(self, plain_bytes, key_bytes):
k = S[(S[i] + S[j]) % 256]
keystream_list.append(k)
cipher_list.append(k ^ plain_bytes[m])

return keystream_list, cipher_list

0 comments on commit b056305

Please sign in to comment.