Python programming blog

Friday, May 28, 2021

Audio encryption & decryption using python

                         This blog contains the code for Audio encryption using python





Step 1: Library installation

* pip install cryptography


Step 2: Import modules

from cryptography.fernet import Fernet


#key generation

key=Fernet.generate_key()

print(key)


Step3: Encryption part

fernet=Fernet(key)

with open('key.key','wb') as filekey:

    filekey.write(key)


with open('key.key','rb') as filekey:

    key=filekey.read()

    

with open('open cv project edited.wav','rb') as file:

    originalaudio=file.read()

    

encrypted=fernet.encrypt(originalaudio)


with open('voice encryption.wav','wb') as encrypted_file:

    encrypted_file.write(encrypted)


Step 4: Decryption part

fernet=Fernet(key)


with open('voice encryption.wav','rb') as enc_file:

    encrypted=enc_file.read()

    

decrypted =fernet.decrypt(encrypted)


with open('voice decryption.wav','wb') as dec_file:

    dec_file.write(decrypted)


Thanks for reading this article..!

1 comment:

  1. Great !!!!! one of the best video of your channel .
    i am big fan of you
    i am sahil

    ReplyDelete