@@ -511,13 +511,15 @@ private void prepareEncryptionDictRev2345(String ownerPassword, String userPassw
511511 COSArray idArray = document .getDocument ().getDocumentID ();
512512
513513 //check if the document has an id yet. If it does not then generate one
514+ byte [] userPasswordBytes = userPassword .getBytes (Charsets .ISO_8859_1 );
515+ byte [] ownerPasswordBytes = ownerPassword .getBytes (Charsets .ISO_8859_1 );
514516 if (idArray == null || idArray .size () < 2 )
515517 {
516518 MessageDigest md = MessageDigests .getMD5 ();
517519 BigInteger time = BigInteger .valueOf (System .currentTimeMillis ());
518520 md .update (time .toByteArray ());
519- md .update (ownerPassword . getBytes ( Charsets . ISO_8859_1 ) );
520- md .update (userPassword . getBytes ( Charsets . ISO_8859_1 ) );
521+ md .update (ownerPasswordBytes );
522+ md .update (userPasswordBytes );
521523 md .update (document .getDocument ().toString ().getBytes (Charsets .ISO_8859_1 ));
522524
523525 byte [] id = md .digest (this .toString ().getBytes (Charsets .ISO_8859_1 ));
@@ -532,15 +534,16 @@ private void prepareEncryptionDictRev2345(String ownerPassword, String userPassw
532534 COSString id = (COSString ) idArray .getObject (0 );
533535
534536 byte [] ownerBytes = computeOwnerPassword (
535- ownerPassword . getBytes ( Charsets . ISO_8859_1 ) ,
536- userPassword . getBytes ( Charsets . ISO_8859_1 ) , revision , length );
537+ ownerPasswordBytes ,
538+ userPasswordBytes , revision , length );
537539
540+ byte [] idBytes = id .getBytes ();
538541 byte [] userBytes = computeUserPassword (
539- userPassword . getBytes ( Charsets . ISO_8859_1 ) ,
540- ownerBytes , permissionInt , id . getBytes () , revision , length , true );
542+ userPasswordBytes ,
543+ ownerBytes , permissionInt , idBytes , revision , length , true );
541544
542- setEncryptionKey (computeEncryptedKey (userPassword . getBytes ( Charsets . ISO_8859_1 ) , ownerBytes ,
543- null , null , null , permissionInt , id . getBytes () , revision , length , true , false ));
545+ setEncryptionKey (computeEncryptedKey (userPasswordBytes , ownerBytes ,
546+ null , null , null , permissionInt , idBytes , revision , length , true , false ));
544547
545548 encryptionDictionary .setOwnerKey (ownerBytes );
546549 encryptionDictionary .setUserKey (userBytes );
0 commit comments