{"id":17309557,"url":"https://github.com/galkahana/pdf-recrypt","last_synced_at":"2026-03-05T20:22:58.676Z","repository":{"id":141787238,"uuid":"540405329","full_name":"galkahana/pdf-recrypt","owner":"galkahana","description":"cli for adding, removing or modifying PDF files passwords","archived":false,"fork":false,"pushed_at":"2024-06-10T18:20:23.000Z","size":3256,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-03T00:08:22.967Z","etag":null,"topics":["pdf","pdf-encryption"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/galkahana.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-23T11:20:21.000Z","updated_at":"2024-06-24T21:05:44.000Z","dependencies_parsed_at":"2023-03-17T05:15:45.322Z","dependency_job_id":null,"html_url":"https://github.com/galkahana/pdf-recrypt","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galkahana%2Fpdf-recrypt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galkahana%2Fpdf-recrypt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galkahana%2Fpdf-recrypt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galkahana%2Fpdf-recrypt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/galkahana","download_url":"https://codeload.github.com/galkahana/pdf-recrypt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228265809,"owners_count":17893834,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pdf","pdf-encryption"],"created_at":"2024-10-15T12:29:49.945Z","updated_at":"2026-03-05T20:22:53.619Z","avatar_url":"https://github.com/galkahana.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"A CLI (command line interface) to recreate PDF from original PDF with optional adding or removing or modifying its password.\n\n```bash\nUsage: Recrypt inputfilepath outputfilepath \u003coption(s)\u003e\ninputfilepath - input pdf file path\noutputfilepath - output pdf file path\nOptions:\n        -p, --password password               input pdf password (user or owner). Default is no password\n        -v, --version \u003cd\u003e                     output pdf version. Use 10-17 for pdf1.0-pdf1.7. For AES use 16 or 17. Lower is RC4. Default is input pdf version\n        -u, --user-password password          output pdf password (user password). Default is no password\n        -o, --owner-password password         output pdf owner password. Default is no owner password password\n        -f, --user-protection-flag \u003cd\u003e        output pdf user protection flag. Default is 4 (low res print)\n        -h, --help                      Show this help message\n```\n\n# Binaries downloads\n\nYou can download built executables from the Release section of this repo. Each release includes compressed tar files, with per-platform binaries.\n\n# First time around\n\nThis is a C++ Project using CMake as project builder.\nTo build/develop You will need:\n\n1. a compiler. for win you can use vs studio. choose community version - https://visualstudio.microsoft.com/\n2. cmake - download from here - https://cmake.org/\n\n\n# Building and Installing the project\n\n*PDFWriter requires openssl to supportd PDF 2.0 encryption. if not available it will fallback on disabling this feature.*\n\nOnce you installed pre-reqs, you can now build the project.\n\n## Create the project files\n\nTo build you project start by creating a project file in a \"build\" folder off of the cmake configuration, like this:\n\n```bash\nmkdir build\ncd build\ncmake ..\n```\n\nI won't go on about cmake here, you can check out their website. going forward i'll stick to describing the minimal set of commands\nyou can use for building and installing.\n\n\n## Build and install\n\nOnce you got the project file, you can now build the project. If you created an IDE file, you can use the IDE file to build the project.\nAlternatively you can do so from the command line, again using cmake. \n\nThe following builds the project from its root folder:\n```bash\ncmake --build build --config release\n```\n\nThis will build the project inside the build folder. You will be able to look up the result execultable per how you normally do when building with the relevant build environment. For example, for windows,  the Recrypt/Release folder will have the result file.\n\nIf you want, you can use the \"install\" verb of cmake to install a built product. Use the prefix param to specify where you want the result to be installed to\n\n```bash\ncmake --install ./build --prefix ./etc/install --component executable\n```\n\nThis will install the Recrypt executable in ./etc/install.\n\nif you do not have `cmake --install` as option, you can use a regular build with install target instead, and specify the install target in configuration stage, like this:\n\n```bash\ncd build\ncmake .. -DCMAKE_INSTALL_PREFIX=\"..\\etc\\install\"\ncd ..\n\ncmake --build build/Recrypt --config release --target install\n```\n\n# Running\nThe end result is an executable, so just run it from comman line (it's a regular cli).\n\nThe minimal run requires an input file path and output file path, say on windows:\n```console\netc\\install\\bin\\Recrypt.exe input.pdf output.pdf\n```\n\n\n\n# Features and implementation details\nThis implementation is based on hummus PDF library. It is a simple CLI implementation using the `PDFWriter::Recrypt` method. `Recrypt` copies an origin PDF file to a new PDF file by deep copying the original file Root object (the catalog). Given it's a completely new rewrite of the file, and how Hummus parses files, the created file has only PDF Objects actually used in the origin PDF. This means that if the original PDF is an modified PDF file the new file will not include any \"documnation\" of the midifications. This is very good for create PDF that's compatible with readers that cannot consume modified PDF files. Either user or owner passwords can be used to decrypt the new file, given that either of them provides full access to parse the PDF file, which is the only thing required to recreate a new file.\n\nPDF provides and option to have both a \"user\" password and an \"owner\" password. In such a case, a user providing the \"user\" password will have a more limited access to the PDF file, like not being able to edit it, or print only a lower resolution of the file. If providing \"owner\" password full access is granted. To control what options are available when providing \"user\" password use the `--user-protection-flag` option. The flag is a bit field that’s explained in section 3.5.2 in the PDF specs. The short version is provided here:\n\n- bit 3 should be 1 if you want to allow the user to print the document\n- bit 4 should be 1 if you want to allow modification of the document\n- bit 5 should be 1 if you want to allow copying or extracting text and graphics from the document\n- bit 6 should be 1 if you want to allow adding text annotations, fill form field. If bit 4 is set it allows to create new fields. like a signature.\n- bit 9 should be 1 if you want to allow filling forms, even if bit 6 is clear.\n- bit 10 should be 1 if you want to allow extracting text and graphics in support of accessibility only, even if bit 5 is clear.\n- bit 11 should be 1 if you want to allow assembling the document. rotate, insert, delete pages, bookmarks and thumbnails.\n- bit 12 should be 1 if you want to allow printing the document in a good res. Setting just 3 will normally print a low res form.\n\nA good choice for most cases is 4, which means only the low res print is allowed. This is the sort of a safe exchange scenario. Note that Hummus handles the rest of the unexplained fields and also the two complement part that the specs require - so you don’t have to. but it’s ok if you’ll pass a flag in this form too. if you must.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgalkahana%2Fpdf-recrypt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgalkahana%2Fpdf-recrypt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgalkahana%2Fpdf-recrypt/lists"}