Please help me in retrieving password from pdf

2014-07-22
2014-07-25
  • senthil kumar
    senthil kumar
    2014-07-22

    Hi there

    I got to see through jpdf code, it looks good for pdf manipulation tool. I want to find out the password for the password protected pdf, I got to see the following snippet of your code in de.intarsys.pdf.crypt.StandardSecurityHandler:

    protected byte[] getU() {
    COSString u = getEncryption().cosGetField(DK_U).asString();
    try
    {
    for(byte b : u.byteValue())
    {
    System.out.println(b);
    }
    System.out.println("----------------"+new String(u.byteValue(),"UTF-16BE"));
    //how to display password ?
    }
    catch(Exception e)
    {
    e.printStackTrace();;
    }
    if (u == null) {
    return null;
    }
    return u.byteValue();
    }

    Please help me with your solution asap.

    Regards
    Sentil

     
    Last edit: senthil kumar 2014-07-22
  • mtraut
    mtraut
    2014-07-25

    It would not make much sense if you could read out the password, does it?

     
    • senthil kumar
      senthil kumar
      2014-07-25

      Hi

      Our requirement is to get the password from the pdf document and render the passwordless.
      I got the code snippet where I have explicitly set the password to user entered password in de.intarsys.pdf.crypt.StandardSecurityHandlerR3:

      @Override
      public boolean authenticateUser(byte[] user) throws COSSecurityException {

      byte[] entryU = getU();
      // byte[] tempU = createUserPassword(user);
      // Commented by me
      tempU = getU();
      //Explicitly setting the user password to doc password
      .....//rest of the code goes here

      }
      The attached password.pdf has the password as 'test'
      But it get the blank document as attached without password, the file size is
      len1 : : : 49755 //Before the document is decrypted
      len2 : : : 49226 //After the document is decrypted
      Please help me asap.

      Regards
      Sentil

       
      Last edit: senthil kumar 2014-07-26
      Attachments