python密碼學文件解密實現(xiàn)教程
更新時間:2022年05月24日 09:30:47 作者:菜鳥教程
這篇文章主要為大家介紹了python密碼學文件解密實現(xiàn)教程,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
在本章中,我們將討論使用Python解密加密文件.請注意,對于解密過程,我們將遵循相同的過程,但不是指定輸出路徑,而是關注輸入路徑或加密的必要文件.
代碼
以下是使用Python解密加密文件的示例代碼;
#!/usr/bin/python #?----------------?READ?ME?--------------------------------------------- #?This?Script?is?Created?Only?For?Practise?And?Educational?Purpose?Only #?This?Script?Is?Created?For?http://bitforestinfo.blogspot.in #?This?Script?is?Written?By # # ################################################## ########?Please?Don't?Remove?Author?Name?######### ###############?Thanks?########################### ################################################## # # #?=================Other?Configuration================ #?Usages?: usage?=?"usage:?%prog?[options]?" #?Version Version="%prog?0.0.1" #?==================================================== #?Import?Modules import?optparse,?sys,os from?toolkit?import?processor?as?ps def?main(): ???parser?=?optparse.OptionParser(usage?=?usage,version?=?Version) ???parser.add_option( ??????'-i','--input',type?=?'string',dest?=?'inputfile', ??????help?=?"File?Input?Path?For?Encryption",?default?=?None) ??? ???parser.add_option( ??????'-o','--output',type?=?"string",dest?=?'outputfile', ??????help?=?"File?Output?Path?For?Saving?Encrypter?Cipher",default?=?".") ??? ???parser.add_option( ??????'-p','--password',type?=?"string",dest?=?'password', ??????help?=?"Provide?Password?For?Encrypting?File",default?=?None) ??????(options,?args)?=??parser.parse_args() ??????#?Input?Conditions?Checkings ??????if?not?options.inputfile?or?not?os.path.isfile(options.inputfile): ?????????print?"?[Error]?Please?Specify?Input?File?Path" ?????????exit(0) ??????if?not?options.outputfile?or?not?os.path.isdir(options.outputfile): ?????????print?"?[Error]?Please?Specify?Output?Path" ?????????exit(0) ??????if?not?options.password: ?????????print?"?[Error]?No ?????????exit(0) ??????inputfile?=?options.inputfile ??????outputfile?=?options.outputfile ??????password?=?options.password ??????work?=?"D" ??????ps.FileCipher(inputfile,outputfile,password,work) ??????return if?__name__?==?'__main__': ???main()
您可以使用以下命令執(zhí)行上述代碼 :
python pyfilecipher-decrypt.py -i encrypted_file_path -p password
輸出
執(zhí)行上面顯示的命令時,您可以觀察以下代碼 :

注意 : 輸出指定加密前和解密后的哈希值,它記錄了同一文件已加密并且過程成功.
以上就是python密碼學文件解密實現(xiàn)教程的詳細內(nèi)容,更多關于python密碼學文件解密的資料請關注腳本之家其它相關文章!
相關文章
基于pytorch實現(xiàn)對圖片進行數(shù)據(jù)增強
圖像數(shù)據(jù)增強是一種在訓練機器學習和深度學習模型時常用的策略,尤其是在計算機視覺領域,具體而言,它通過創(chuàng)建和原始圖像稍有不同的新圖像來擴大訓練集,本文給大家介紹了如何基于pytorch實現(xiàn)對圖片進行數(shù)據(jù)增強,需要的朋友可以參考下2024-01-01
Pandas DataFrame數(shù)據(jù)存儲格式比較分析
Pandas 支持多種存儲格式,在本文中將對不同類型存儲格式下的Pandas Dataframe的讀取速度、寫入速度和大小的進行測試對比,有需要的朋友可以借鑒參考下,希望能夠有所幫助2023-09-09
Python使用email模塊對郵件進行編碼和解碼的實例教程
Python中我們一般使用SMTP模塊來首發(fā)郵件,而用email模塊來處理郵件編碼,本文我們就來詳細看一下Python使用email模塊對郵件進行編碼和解碼的實例教程,需要的朋友可以參考下2016-07-07

