'Use diffie hellman key exchange algorithm to encrypt and decrypt files in python

I want to implement an algorithm which will encrypt and decrypt files using diffie hellman algorithm but I am unable to find any solution for the same. Here is my diffie hellman code:

import pyDH
d1 = pyDH.DiffieHellman()
d2 = pyDH.DiffieHellman()
d1_pubkey = d1.gen_public_key()
d2_pubkey = d2.gen_public_key()
d1_sharedkey = d1.gen_shared_key(d2_pubkey)
d2_sharedkey = d2.gen_shared_key(d1_pubkey)

I want to encrypt files using this algorithm. Can anyone help me with this please?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source