from pyfilesec import SecFile s = SecFile("creditcard.csv") s.encrypt("pub_RSA.pem")
with open(datafile, 'wb') as file: file.write("confidential data, e.g., participant's drug-use history") # To set up for encryption, give it to a SecFile: sf = SecFile(datafile) msg = 'make a file:\n file name: "%s"\n contents: "%s"' print(msg % (sf.file, sf.snippet)) print(' is encrypted: %s' % sf.is_encrypted) # These particular RSA keys are ONLY for testing # see pyfilesec.genrsa() to make your own keys) # paths to new tmp files that hold the keys pubkey, privkey, passphrase = GenRSA().demo_rsa_keys() # To encrypt the file, use the RSA public key: sf.encrypt(pubkey) msg = 'ENCRYPT it:\n file name: "%s"\n contents (base64): "%s . . ."' print(msg % (sf.file, sf.snippet)) print(' is encrypted: %s' % sf.is_encrypted) # To decrypt the file, use the matching RSA private key (and its passphrase): sf.decrypt(privkey, passphrase) msg = 'DECRYPT it:\n file name: "%s"\n contents: "%s"' print(msg % (sf.file, sf.snippet)) print(' is encrypted: %s' % sf.is_encrypted) # clean-up the tmp files: for file in [sf.file, pubkey, privkey, passphrase]: os.unlink(file) # The contents of this file are in the public domain.
'decrypt:\n' + decrypt(str(self.etxt.get()), privatekey) + '\n') self.history.config(state='disabled') self.history.see(Tkinter.END) #print "decrypt click!" def clear_both(self): self.etxt.set('') self.ptxt.set('') def clear_history(self): self.history.config(state='normal') self.history.delete(0.0, Tkinter.END) self.history.config(state='disabled') pass '''if __name__ == "__main__": app = crypt_mod(None) app.title('Honey Encryption(RSA)') app.mainloop() ''' if __name__ == "__main__": SS = SecFile("creditcard.enc") rr = raw_input("Enter Phrase: ") SS.decrypt("priv_RSA.pem", rr) app = crypt_mod(None) app.title('Honey Encryption(RSA)') app.mainloop() SS.encrypt("pub_RSA.pem")
with open(datafile, 'wb') as file: file.write("confidential data, e.g., participant's drug-use history") # To set up for encryption, give it to a SecFile: sf = SecFile(datafile) msg = 'make a file:\n file name: "%s"\n contents: "%s"' print msg % (sf.file, sf.snippet) print ' is encrypted: %s' % sf.is_encrypted # These particular RSA keys are ONLY for testing # see pyfilesec.genrsa() to make your own keys) # paths to new tmp files that hold the keys pubkey, privkey, passphrase = GenRSA().demo_rsa_keys() # To encrypt the file, use the RSA public key: sf.encrypt(pubkey) msg = 'ENCRYPT it:\n file name: "%s"\n contents (base64): "%s . . ."' print msg % (sf.file, sf.snippet) print ' is encrypted: %s' % sf.is_encrypted # To decrypt the file, use the matching RSA private key (and its passphrase): sf.decrypt(privkey, passphrase) msg = 'DECRYPT it:\n file name: "%s"\n contents: "%s"' print msg % (sf.file, sf.snippet) print ' is encrypted: %s' % sf.is_encrypted # clean-up the tmp files: for file in [sf.file, pubkey, privkey, passphrase]: os.unlink(file) # The contents of this file are in the public domain.
def Close(): s = SecFile("creditcard.csv") s.encrypt("pub_RSA.pem")
def Close(): s = SecFile("fruitcsv.csv") s.encrypt("pub_RSA.pem")