Skip to content

Conversation

emcc2302
Copy link

@emcc2302 emcc2302 commented Oct 6, 2025

Summary

This Pull Request introduces a Graphical User Interface (GUI) for the PDF security scripts, making the tool more accessible and user-friendly. It also integrates the core encryption/decryption logic into a single application and adds a permanent author credit at the bottom of the window.

Description

This change converts the previously command-line-only Python scripts into a functional desktop application using the Tkinter library. Users can now easily select files, input passwords, and choose between the Encrypt and Decrypt operations via buttons, removing the need to edit the source code for configuration.

The application includes robust error handling to guide the user on necessary inputs and dependencies.

The changes are as follows:

  • Created pdf_enc_dec.py: Merged encryption/decryption logic into a single, comprehensive Python file.
  • Implemented Tkinter GUI: Added widgets for file browsing, password entry (User/Open and Owner/Admin), and two action buttons (Encrypt and Decrypt).
  • Added Author Credit: Incorporated a permanent label at the bottom of the application window displaying the text: "Made By Soriful Islam Sk."
  • Improved Dependency Check: Ensured the code relies on the presence of the cryptography library for AES-256 to function correctly.

Checks

in the repository

  • Made no changes that degrades the functioning of the repository
  • Gave each commit a better title (unlike updated README.md)

in the PR

  • Followed the format of the pull_request_template
  • Made the Pull Request in a small level (for the creator's wellfare)
  • Tested the changes you made

Thank You,
Soriful Islam Sk

Screenshot 2025-10-06 215110 Screenshot 2025-10-06 215208 Screenshot 2025-10-06 215257

@emcc2302 emcc2302 changed the title PDF Encription AND Decription Using Python PDF Encryption and Decryption Oct 6, 2025
@DhanushNehru DhanushNehru requested a review from Copilot October 7, 2025 07:24
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR creates a desktop GUI application for PDF encryption and decryption functionality, converting previously command-line-only scripts into a user-friendly Tkinter-based interface.

Key Changes:

  • Created a complete GUI application with file browsing, password entry fields, and encrypt/decrypt buttons
  • Merged core encryption/decryption logic into a single Python file with proper error handling
  • Implemented intuitive user interface elements including file dialogs and message boxes
Comments suppressed due to low confidence (1)

PDF ENC & DEC/pdf_enc_dec.py:1

  • The author credit label referenced in the PR description is missing from the GUI implementation. According to the description, there should be a permanent author credit at the bottom of the application window.
import tkinter as tk

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

# Try to decrypt using the provided password
result = reader.decrypt(password)

if result not in (1, 0): # 1 is correct password, 0 is empty password
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition is inverted. According to PyPDF documentation, decrypt() returns 1 for correct password and 0 for incorrect password. The condition should be if result == 0: to properly handle incorrect passwords.

Suggested change
if result not in (1, 0): # 1 is correct password, 0 is empty password
if result == 0: # 1 is correct password, 0 is incorrect password

Copilot uses AI. Check for mistakes.

@emcc2302
Copy link
Author

emcc2302 commented Oct 7, 2025

hey @DhanushNehru i just changed the login for dec kindly check my pr #496

@DhanushNehru DhanushNehru requested a review from Copilot October 8, 2025 14:48
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

writer.encrypt(
user_password=user_password,
owner_password=owner_password,
permissions_flag=0xFFC0, # Common flag to restrict editing/copying for the user
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic number 0xFFC0 should be documented or replaced with named constants. Consider defining this as a constant with a descriptive name like RESTRICTED_USER_PERMISSIONS and documenting what specific permissions it grants/restricts.

Copilot uses AI. Check for mistakes.

# 1. ATTEMPT DECRYPTION WITH USER PASSWORD
result = reader.decrypt(user_password)

if result not in (1, 0): # 1 and 0 indicate successful decryption
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic numbers 1 and 0 for decryption success should be replaced with named constants or use the pypdf library's defined constants if available. This would make the code more readable and maintainable.

Copilot uses AI. Check for mistakes.

result = reader.decrypt(owner_password)

# 3. CHECK FINAL DECRYPTION STATUS
if result not in (1, 0):
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same magic numbers 1 and 0 repeated. Consider defining constants like DECRYPTION_SUCCESS_CODES = (0, 1) at the module level and using them consistently throughout the decryption logic.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants