Skip to content

Commit

Permalink
STY: Apply ruff rule N806 for some file (#2149)
Browse files Browse the repository at this point in the history
  • Loading branch information
exiledkingcc authored Sep 10, 2023
1 parent e090717 commit f659956
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 155 deletions.
14 changes: 7 additions & 7 deletions pypdf/_crypt_providers/_fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@

class CryptRC4(CryptBase): # type: ignore
def __init__(self, key: bytes) -> None:
self.S = bytearray(range(256))
self.s = bytearray(range(256))
j = 0
for i in range(256):
j = (j + self.S[i] + key[i % len(key)]) % 256
self.S[i], self.S[j] = self.S[j], self.S[i]
j = (j + self.s[i] + key[i % len(key)]) % 256
self.s[i], self.s[j] = self.s[j], self.s[i]

def encrypt(self, data: bytes) -> bytes:
S = bytearray(self.S)
s = bytearray(self.s)
out = [0 for _ in range(len(data))]
i, j = 0, 0
for k in range(len(data)):
i = (i + 1) % 256
j = (j + S[i]) % 256
S[i], S[j] = S[j], S[i]
x = S[(S[i] + S[j]) % 256]
j = (j + s[i]) % 256
s[i], s[j] = s[j], s[i]
x = s[(s[i] + s[j]) % 256]
out[k] = data[k] ^ x
return bytes(bytearray(out))

Expand Down
Loading

0 comments on commit f659956

Please sign in to comment.