西西軟件園多重安全檢測(cè)下載網(wǎng)站、值得信賴的軟件下載站!
西西首頁(yè) 電腦軟件 安卓軟件 電腦游戲 安卓游戲 排行榜 專題合集

PDF加密小工具

v1.0
  • PDF加密小工具v1.0
  • 軟件大小:9.4M
  • 更新時(shí)間:2021-09-24 09:52
  • 軟件語(yǔ)言:中文
  • 軟件廠商:
  • 軟件類別:國(guó)產(chǎn)軟件 / 免費(fèi)軟件 / 加密解密
  • 軟件等級(jí):3級(jí)
  • 應(yīng)用平臺(tái):WinXP, Win7, win8
  • 官方網(wǎng)站:暫無(wú)
  • 應(yīng)用備案:
好評(píng):50%
壞評(píng):50%

軟件介紹

PDF加密小工具,由論壇用戶原創(chuàng)制作分享的一個(gè)PDF加密工具,可以設(shè)置密碼,將pdf文檔一鍵加密,可以分別設(shè)置瀏覽密碼和編輯密碼,給你的重要文檔設(shè)置雙重保護(hù)。本站提供PDF加密工具單文件程序下載,其中源碼數(shù)據(jù)如下,需要對(duì)PDF文件進(jìn)行加密處理的朋友們可以下載試試。


PDF加密工具功能

設(shè)置pdf文檔加密和編輯密碼

自由設(shè)置文件路徑格式

源碼一覽

# -*- coding: utf-8 -*-

# ☯ Author: ChinaPython

# ☯ Date  : 2021/9/16 19:01

import os

import PySimpleGUI as sg

from PyPDF2 import PdfFileWriter

from PyPDF2 import PdfFileReader

class EncryptTool:

    def __init__(self):

        self.layout = [

            [

                sg.Text(text="閱覽密碼"),

                sg.InputText(do_not_clear=True, default_text="默認(rèn):admin", text_color='gray', key='psw_a', size=(17, 1)),

                sg.Text(text="編輯密碼"),

                sg.InputText(do_not_clear=True, default_text="默認(rèn):admin", text_color='gray', key='psw_b', size=(17, 1)),

            ],

            [

                sg.Input(do_not_clear=True, default_text='選擇需要轉(zhuǎn)換的PDF文件(默認(rèn)同路徑)', text_color='gray', key='path'),

                sg.FileBrowse(button_text='選擇文件', key='file'),

            ],

            [

                sg.Input(do_not_clear=True, default_text='轉(zhuǎn)換后PDF文件存儲(chǔ)路徑', text_color='gray', key='path2'),

                sg.FolderBrowse(button_text='輸出目錄', key='folder'),

            ],

            [sg.Text(text="", size=(48, 4), background_color="white", text_color="red", key="msg")],

            [sg.Button(button_text='開始加密', key='start', size=(48, 2))],

        ]

        self.window = sg.Window('PDF加密小工具(吾愛(ài)破解論壇)', self.layout, icon='icon.ico')

    @staticmethod

    def __encrypt(unencrypted_pdf, read_password, encrypted_pdf=None, owner_password=None):

        unencrypted_pdf = "加密_" + unencrypted_pdf if encrypted_pdf is None else unencrypted_pdf

        owner_password = owner_password if owner_password is None else owner_password

        try:

            content = PdfFileReader(unencrypted_pdf)

            writer = PdfFileWriter()

            [writer.addPage(content.getPage(page)) for page in range(content.getNumPages())]

            writer.encrypt(user_pwd=read_password, owner_pwd=owner_password, use_128bit=False)

            with open(encrypted_pdf, 'wb') as out:

                writer.write(out)

            return os.path.exists(encrypted_pdf)

        except Exception as e:

            return e

    # 運(yùn)行入口

    def run(self):

        while True:

            event, values = self.window.Read()

            if event == 'start':

                a, b, c, d = values['psw_a'], values['psw_b'], values['path'], values['path2']

                if os.path.exists(c) is False or str(c).lower().endswith(".pdf") is False:

                    self.window.Element('msg').Update("加載目錄失敗,請(qǐng)檢測(cè)路徑的合法性")

                    continue

                a = "admin" if "默認(rèn):" in a or len(a) == 0 else a

                b = "admin" if "默認(rèn):" in b or len(b) == 0 else b

                filepath, filename = os.path.split(c)

                d = f"nspzsz8/加密_{filename}" if os.path.isdir(d) is True else f"{filepath}/加密_{filename}"

                msg = self.__encrypt(c, a, d, b)

                if msg is not True:

                    self.window.Element('msg').Update(f"加密失敗:{msg}")

                    continue

                self.window.Element('msg').Update(

                    f"閱覽密碼:{a}\n編輯密碼:\n目標(biāo)文件:{c}\n輸出文件:nxthu2k"

                )

            if event is None:

                break

        self.window.close()

if __name__ == '__main__':

    start = EncryptTool()

    start.run()

軟件標(biāo)簽: PDF加密 PDF 文檔工具

其他版本下載

發(fā)表評(píng)論

昵稱:
表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
查看所有(0)條評(píng)論 > 字?jǐn)?shù): 0/500

TOP
軟件下載