src/reportlab/lib/pdfencrypt.py
branchpy33
changeset 3723 99aa837b6703
parent 3721 0c93dd8ff567
child 3746 b7143a1c34c6
--- a/src/reportlab/lib/pdfencrypt.py	Sun Feb 17 12:13:56 2013 +0000
+++ b/src/reportlab/lib/pdfencrypt.py	Tue Apr 30 14:28:14 2013 +0100
@@ -4,13 +4,13 @@
 
 """helpers for pdf encryption/decryption"""
 
-import string, sys, os
+import sys, os
 try:
     from hashlib import md5
 except ImportError:
     from md5 import md5
 
-from reportlab.lib.utils import getStringIO
+from reportlab.lib.utils import getBytesIO
 import tempfile
 
 from reportlab.pdfgen.canvas import Canvas
@@ -176,7 +176,7 @@
         return out
 
 def hexchar(x):
-    return chr(string.atoi(x, 16))
+    return chr(int(x, 16))
 
 def hexText(text):
     "a legitimate way to show strings in PDF"
@@ -196,7 +196,7 @@
         out = out + char
     return out
 
-PadString = string.join(list(map(hexchar, string.split(string.strip(padding)))), "")
+PadString = ''.join(map(hexchar, padding.strip().split()))
 
 def encryptionkey(password, OwnerKey, Permissions, FileId1, revision=2):
     # FileId1 is first string of the fileid array
@@ -408,7 +408,7 @@
     firstPageSize = bboxInfo['PageForms0'][2:]
 
     #now make a new PDF document
-    buf = getStringIO()
+    buf = getBytesIO()
     canv = Canvas(buf, pagesize=firstPageSize)
 
     # set a standard ID while debugging