Skip to content

Commit 4cd8234

Browse files
committed
PDFBOX-5660: optimize, as suggested by Valery Bokov; closes #423
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1932135 13f79535-47bb-0310-9956-ffa450edef68
1 parent 160ade2 commit 4cd8234

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ public void prepareForDecryption(PDEncryption encryption, COSArray documentIDArr
249249
}
250250

251251
byte[] mdResult;
252-
if (encryption.getVersion() == 4 || encryption.getVersion() == 5)
252+
int encryptionVersion = encryption.getVersion();
253+
if (encryptionVersion == 4 || encryptionVersion == 5)
253254
{
254255
if (!isDecryptMetadata())
255256
{
@@ -258,7 +259,7 @@ public void prepareForDecryption(PDEncryption encryption, COSArray documentIDArr
258259
sha1Input = Arrays.copyOf(sha1Input, sha1Input.length + 4);
259260
System.arraycopy(new byte[]{ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff}, 0, sha1Input, sha1Input.length - 4, 4);
260261
}
261-
if (encryption.getVersion() == 4)
262+
if (encryptionVersion == 4)
262263
{
263264
mdResult = MessageDigests.getSHA1().digest(sha1Input);
264265
}

0 commit comments

Comments
 (0)