@@ -23,7 +23,6 @@ This file is part of the iText (R) project.
23
23
package com .itextpdf .kernel .pdf ;
24
24
25
25
import com .itextpdf .commons .utils .SystemUtil ;
26
- import com .itextpdf .kernel .exceptions .PdfException ;
27
26
import com .itextpdf .kernel .crypto .IDecryptor ;
28
27
import com .itextpdf .kernel .crypto .OutputStreamEncryption ;
29
28
import com .itextpdf .kernel .crypto .securityhandler .PubKeySecurityHandler ;
@@ -38,7 +37,9 @@ This file is part of the iText (R) project.
38
37
import com .itextpdf .kernel .crypto .securityhandler .StandardHandlerUsingStandard40 ;
39
38
import com .itextpdf .kernel .crypto .securityhandler .StandardSecurityHandler ;
40
39
import com .itextpdf .kernel .exceptions .KernelExceptionMessageConstant ;
40
+ import com .itextpdf .kernel .exceptions .PdfException ;
41
41
import com .itextpdf .kernel .security .IExternalDecryptionProcess ;
42
+
42
43
import java .io .ByteArrayOutputStream ;
43
44
import java .io .IOException ;
44
45
import java .io .OutputStream ;
@@ -255,17 +256,17 @@ public PdfEncryption(PdfDictionary pdfDict, Key certificateKey, Certificate cert
255
256
}
256
257
257
258
public static byte [] generateNewDocumentId () {
258
- MessageDigest md5 ;
259
+ MessageDigest sha512 ;
259
260
try {
260
- md5 = MessageDigest .getInstance ("MD5 " );
261
+ sha512 = MessageDigest .getInstance ("SHA-512 " );
261
262
} catch (Exception e ) {
262
263
throw new PdfException (KernelExceptionMessageConstant .PDF_ENCRYPTION , e );
263
264
}
264
265
long time = SystemUtil .getTimeBasedSeed ();
265
266
long mem = SystemUtil .getFreeMemory ();
266
267
String s = time + "+" + mem + "+" + (seq ++);
267
268
268
- return md5 .digest (s .getBytes (StandardCharsets .ISO_8859_1 ));
269
+ return sha512 .digest (s .getBytes (StandardCharsets .ISO_8859_1 ));
269
270
}
270
271
271
272
/**
0 commit comments