Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added cryptography program in python folder #989

Merged
merged 1 commit into from
Oct 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from cryptography.fernet import Fernet

def genratePassKey():
key = Fernet.generate_key()
print(key)
print(type(key))
abc = open("PasswordKey.key",'wb')
abc.write(key)
abc.close()

def getMyKey():
abc = open("PasswordKey.key",'rb')
return abc.read()

def encryptMessage(message_normal):
key = getMyKey()
k = Fernet(key)
encrypted_Message = k.encrypt(message_normal)
return encrypted_Message

def decryptMessage(message_secret):
key = getMyKey()
k = Fernet(key)
decrypted_Message = k.decrypt(message_secret)
return decrypted_Message

encryptMessage(b" HEY PYTHON LEARNER")

decryptMessage(b'gAAAAABhbBReu34y2Z5wPDu_2GHtdtSdXl3iLvwYtOk8F5pIc9HToKfJmGLWXbCYiwhWTFE77_f3J_S0_plkssSoSOzS6pdOEfEWoOSTg7BNao5S_49NgJc=')