Python for RSA installation encryption

Source: Internet
Author: User

First, download ez_setup.py (http://peak.telecommunity.com/dist/ez_setup.py)

Second, use the python explanation to execute it (such as open the Py file with idle, as explained by F5)

After the installation is complete, several EXE executables will be generated under the Scripts folder. (e.g., D:\Python27\Scripts directory)

Four, you can copy the previously downloaded file Rsa-3.1.1-py2.7.egg to the D:\Python27\Scripts directory, and then switch to cmd in the D:\Python27\Scripts directory, execute the egg file: Easy_ Install.exe Rsa-3.1.1-py2.7.egg

Encryption instance

Import Osimport sysimport mathdef getdatafromfile (filename): f = open (filename) n = Int (F.read (), +) print (' * ' *77 ) print (filename) print (Hex (n)) print (' * ' *77) return (n) def my_rsa_encrypt (SRC, D, n): x = POW (src, D, N) Print (' * ' *77) print ("Encrypted Data is:") print (Hex (x)) print (' * ' *77) return x def my_rsa_decrypt (src  , E, n): y = Pow (src, e, n) print (' * ' *77) print ("Decrypted Data is:") print (Hex (y)) print (' * ' *77) return Y path = OS.GETCWD () #====================================fname = path + "\\Firm_N.txt" Plaintdata = Getdatafromfile ( fname) fname = path + "\\Manuf_private_d.txt" D = getdatafromfile (fname) fname = path + "\\Manuf_N.txt" N = Getdatafromfile (fn AME) EncryptedData = My_rsa_encrypt (Plaintdata, D, n) #====================================fname = path + "\\Firm_public _e.txt "Plaintdata = Getdatafromfile (fname) fname = path +" \\Manuf_private_d.txt "D = getdatafromfile (fname) fname = path +" \\Manuf_N.txt "N = GetdatafroMfile (fname) EncryptedData = My_rsa_encrypt (Plaintdata, D, N) #==================================== 

  

Python for RSA installation encryption

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.