Hi, I'm facing problem on calcualting hash of pdf document using iText. My problem is that i want to get the same hash for the same PDF document but everytime i get different hash for the same PDF document.
I've tried the solution of setting the fixed time to get the same hash mentioned at : http://www.mail-archive.com/[email protected]/msg28468.html But this solution did not work for me. I'm attaching the code snippet which i used to get the hash of PDF document. Each time hash is different for same PDF document... ByteArrayOutputStream m_objBaos = new ByteArrayOutputStream(); byte[] doc = //document read as byte[]; PdfReader m_objReader = new PdfReader(); PdfStamper m_objStamper = PdfStamper.createSignature(m_objReader, m_objBaos, '\0', null, true); PdfSignatureAppearance m_objSigApp = m_objStamper.getSignatureAppearance(); PdfDictionary obj_dic = new PdfDictionary(); obj_dic.put(PdfName.FT, PdfName.SIG); obj_dic.put(PdfName.FILTER, new PdfName("Adobe.PPKMS")); obj_dic.put(PdfName.SUBFILTER, new PdfName("adbe.pkcs7.sha1")); Calendar cal = Calendar.getInstance(); long l = 1156153389444L; cal.setTimeInMillis(l); m_objSigApp.setSignDate(cal); m_objSigApp.setCryptoDictionary(obj_dic); HashMap exc = new HashMap(); exc.put(PdfName.CONTENTS, new Integer(20480)); m_objSigApp.preClose(exc); MessageDigest messageDigest = MessageDigest.getInstance("SHA1"); byte buf[] = new byte[8192]; int n; InputStream inp = m_objSigApp.getRangeStream(); while ((n = inp.read(buf)) > 0) { messageDigest.update(buf, 0, n); } byte[] m_byteArrHash = messageDigest.digest(); I hope you can help me fix this problem. Thanks in advance! Waiting for your reply.. Best regards, Israr Ahmed -- View this message in context: http://www.nabble.com/Problem-with-calculating-hash-in-IText-tp24917821p24917821.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
