-
Notifications
You must be signed in to change notification settings - Fork 603
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Align /ID entry creation with 14.4 File Identifiers (#876)
Co-authored-by: Andreas Rosdal <41650711+andreasrosdal@users.noreply.github.com>
- Loading branch information
1 parent
b9a3ea1
commit 1d5325f
Showing
8 changed files
with
274 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
openpdf/src/test/java/com/lowagie/text/pdf/PdfEncryptionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.lowagie.text.pdf; | ||
|
||
import org.bouncycastle.util.encoders.Hex; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertArrayEquals; | ||
|
||
public class PdfEncryptionTest { | ||
|
||
@Test | ||
public void getFileIdChangingPartTest() { | ||
// HEX encoded, valid format | ||
assertArrayEquals(Hex.decode("c547234acb212b7cd65ba961f9e9acae"), | ||
PdfEncryption.getFileIdChangingPart(new PdfLiteral("<c547234acb212b7cd65ba961f9e9acae><c547234acb212b7cd65ba961f9e9acae>"))); | ||
assertArrayEquals(Hex.decode("1527b6788ff5fb71d8c0bd6642fcbe47"), | ||
PdfEncryption.getFileIdChangingPart(new PdfLiteral("<c547234acb212b7cd65ba961f9e9acae><1527b6788ff5fb71d8c0bd6642fcbe47>"))); | ||
assertArrayEquals(Hex.decode("c547234acb212b7cd65ba961f9e9acae"), | ||
PdfEncryption.getFileIdChangingPart(new PdfLiteral("[<c547234acb212b7cd65ba961f9e9acae><c547234acb212b7cd65ba961f9e9acae>]"))); | ||
assertArrayEquals(Hex.decode("1527b6788ff5fb71d8c0bd6642fcbe47"), | ||
PdfEncryption.getFileIdChangingPart(new PdfLiteral("[<c547234acb212b7cd65ba961f9e9acae><1527b6788ff5fb71d8c0bd6642fcbe47>]"))); | ||
|
||
// not-HEX encoded, valid format | ||
assertArrayEquals("abc".getBytes(), | ||
PdfEncryption.getFileIdChangingPart(new PdfLiteral("<abc><abc>"))); | ||
assertArrayEquals("def".getBytes(), | ||
PdfEncryption.getFileIdChangingPart(new PdfLiteral("<abc><def>"))); | ||
|
||
// invalid format | ||
assertArrayEquals("c547234acb212b7cd65ba961f9e9acae".getBytes(), | ||
PdfEncryption.getFileIdChangingPart(new PdfLiteral("c547234acb212b7cd65ba961f9e9acae"))); | ||
assertArrayEquals("<c547234acb212b7cd65ba961f9e9acae>1527b6788ff5fb71d8c0bd6642fcbe47".getBytes(), | ||
PdfEncryption.getFileIdChangingPart(new PdfLiteral("<c547234acb212b7cd65ba961f9e9acae>1527b6788ff5fb71d8c0bd6642fcbe47"))); | ||
assertArrayEquals("c547234acb212b7cd65ba961f9e9acae".getBytes(), | ||
PdfEncryption.getFileIdChangingPart(new PdfLiteral("c547234acb212b7cd65ba961f9e9acae"))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.