fixes for ARC4

pull/1/head
cybjit 2014-09-07 18:38:22 +02:00
parent f9a67db89b
commit cc733c8217
2 changed files with 2 additions and 1 deletions

View File

@ -37,3 +37,4 @@ class Arcfour(object):
encrypt = decrypt = process encrypt = decrypt = process
new = Arcfour

View File

@ -342,7 +342,7 @@ class PDFStandardSecurityHandler(object):
hash.update(self.docid[0]) # 3 hash.update(self.docid[0]) # 3
result = ARC4.new(key).encrypt(hash.digest()) # 4 result = ARC4.new(key).encrypt(hash.digest()) # 4
for i in range(1, 20): # 5 for i in range(1, 20): # 5
k = b''.join(chr(ord(c) ^ i) for c in key) k = b''.join(six.int2byte(c ^ i) for c in six.iterbytes(key))
result = ARC4.new(k).encrypt(result) result = ARC4.new(k).encrypt(result)
result += result # 6 result += result # 6
return result return result