initial commit
Browse files
crypto.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from cryptography.fernet import Fernet
|
3 |
+
|
4 |
+
# Generate a key and instantiate a Fernet instance
|
5 |
+
key = Fernet.generate_key()
|
6 |
+
cipher_suite = Fernet(key)
|
7 |
+
|
8 |
+
def encrypt_string(input_string):
|
9 |
+
encrypted_text = cipher_suite.encrypt(input_string.encode())
|
10 |
+
return encrypted_text.decode()
|
11 |
+
|
12 |
+
# Create the Gradio interface
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=encrypt_string,
|
15 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter a string to encrypt..."),
|
16 |
+
outputs="text",
|
17 |
+
title="AES Encryption with Fernet",
|
18 |
+
description="Enter a string to encrypt it using AES encryption with Fernet."
|
19 |
+
)
|
20 |
+
|
21 |
+
# Launch the interface
|
22 |
+
iface.launch()
|