On my Linux Debian server, using python, I am trying to read a file of names line-by-line and encrypt it using the public RSA. Then I want to compare the encrypted line to another file that I have, which is also encrypted. If they are equal to each other I would like to print out the name in the decrypted and encrypted form. I have never used python before, so any help would be much appreciated.
#!/usr/bin/python
from Crypto.PublicKey import RSA
key = RSA.generate(2048)
names = open('names.txt')
cipher = open('ciphertext.txt',"r")
readname = names.readline()
readcipher = cipher.readlines()
while readname:
enc_name = pubkey.encrypt(names,0)
if enc_name == readcipher:
print readname
readname = names.readline()
names.close()
cipher.close()
I have no idea what your actual question is but maybe this will help?
for name_plaintext,name_encoded in zip(names,cipher):
if do_encode(name_plaintext) == name_encoded:
print name_decoded,"==>",name_encoded
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.