資源簡介
使用python2.7寫的RSA加密解密,支持超過10^10的大素數,可以加解密大于64位的明文,注釋詳盡。
代碼片段和文件信息
#-*-coding:utf-8-*-
‘‘‘
注意事項:
1,命令行格式:
python?RSA.py?-p?rsa_plain.txt?-n?n.txt?-e?e.txt?-d?d.txt?-c?rsa_cipher.txt
2,每次運行時要清空rsa_cipher.txt?和?decrypt_plaintext.txt!??!
‘‘‘
import?sysgetopt
import?math
import?random
#命令行函數
def?main(argv):
???global?p_file
???global?n_file
???global?e_file
???global?d_file
???global?c_file
???p_file?=?‘‘
???n_file?=?‘‘
???e_file?=?‘‘
???d_file?=?‘‘
???c_file?=?‘‘
???try:
??????opts?args?=?getopt.getopt(argv“p:n:e:d:c:“[“ifile=““ofile=“])
???except?getopt.GetoptError:
??????print?‘test.py?-i??-o?‘
??????sys.exit(2)
???for?opt?arg?in?opts:
??????if?opt?==?‘-p‘:???????????????????????#rsa_plain.txt
?????????p_file=?arg
??????elif?opt?==?‘-n‘:???????????????????????#n.txt
?????????n
評論
共有 條評論