Skip to content

Commit

Permalink
Merge pull request py-pdf#393 from lmwgv/master
Browse files Browse the repository at this point in the history
Improve performance of RC4_encrypt in utils.py
  • Loading branch information
mstamy2 authored Apr 1, 2018
2 parents 94a208e + fc87287 commit 1775bdc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions PyPDF2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ def RC4_encrypt(key, plaintext):
j = (j + S[i] + ord_(key[i % len(key)])) % 256
S[i], S[j] = S[j], S[i]
i, j = 0, 0
retval = b_("")
retval = []
for x in range(len(plaintext)):
i = (i + 1) % 256
j = (j + S[i]) % 256
S[i], S[j] = S[j], S[i]
t = S[(S[i] + S[j]) % 256]
retval += b_(chr(ord_(plaintext[x]) ^ t))
return retval
retval.append(b_(chr(ord_(plaintext[x]) ^ t)))
return b_("").join(retval)


def matrixMultiply(a, b):
Expand Down

0 comments on commit 1775bdc

Please sign in to comment.