simple encryption in python code example
Example 1: how to encrypt a string python
from cryptography.fernet import Fernet
message = "my deep dark secret".encode()
f = Fernet(key)
encrypted = f.encrypt(message)
Example 2: encryption using python
import random
text = input ( "Enter text: " )
result = ""
private_key = ""
for i in text:
rand = random.randint ( 1, 125 )
en = rand + ord ( i )
en = chr ( en )
en = str ( en )
private_key = private_key + str ( rand ) + " "
result = result + en
print ( "\nPublic key:", result )
print ( "Private key:", private_key )