开发手册 欢迎您!
软件开发者资料库

解密文件

使用Python进行密码解密文件 - 使用Python从简单简单的步骤学习密码学,从基本到高级概念,包括概述,双强度加密,Python概述和安装,反向密码,凯撒密码,ROT13算法,转置密码,加密转置密码,转置密码解密,文件加密,文件解密,Base64编码和解码,XOR处理,乘法密码,仿射密码,黑客单字母密码,简单替换密码,简单替换密码测试,简单替换密码解密,密码学的Python模块,了解Vignere密码,实现Vignere密码,一次填充密码,一次填充密码的实现,对称和非对称密码,理解RSA算法,创建RSA密钥,RSA密码加密,RSA密码解密,黑客RSA密码。

在本章中,我们将讨论使用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] "# VersionVersion="%prog 0.0.1"# ====================================================# Import Modulesimport optparse, sys,osfrom toolkit import processor as psdef 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)      returnif __name__ == '__main__':   main()

您可以使用以下命令执行上述代码 :

python pyfilecipher-decrypt.py -i encrypted_file_path -p password

输出

执行上面显示的命令时,您可以观察以下代码 :

Decrypting

注意 : 输出指定加密前和解密后的哈希值,它记录了同一文件已加密并且过程成功.