public void Parse(string password) { long xrefPos = findXref(); parseXref(xrefPos); PDFDictionary encrypt = _trailer["Encrypt"] as PDFDictionary; if (encrypt != null) { Encryptor encryptor = new Encryptor(encrypt, _trailer["ID"] as PDFArray); if (!encryptor.AuthenticatePassword(password)) { throw new InvalidPasswordException(new PasswordManager(encryptor)); } encryptor.RecalculateEncryptionKey(); _xref.Encryptor = encryptor; _lexer.SetEncryptor(encryptor); } _xref.Entries.TrimExcess(); _xref.SetTrailer(_trailer); }
/// <summary> /// Verifies the password. /// </summary> /// <param name="password" href="http://msdn.microsoft.com/en-us/library/system.string.aspx">The password to check.</param> /// <returns cref="bool" href="http://msdn.microsoft.com/en-us/library/system.boolean.aspx">true if the password is correct; otherwise, false.</returns> public bool CheckPassword(string password) { return(_encryptor.AuthenticatePassword(password)); }