Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import os | |
| os.system('!pip install pycryptodome -q') | |
| from datetime import datetime | |
| import random | |
| import math | |
| import base64 | |
| import hashlib | |
| from Crypto import Random | |
| from Crypto.Cipher import AES | |
| import rsa | |
| import string | |
| from msg_encX import * | |
| def Encrypt_users_txt(Txt,password): | |
| encMessage = Encrypt_msg(User_message=Txt, user_password=password) | |
| return encMessage | |
| def Decrypt_users_txt(Txt,password): | |
| #Txt = input_parameters[0] | |
| #user_password = input_parameters[1] | |
| encMessage = Decrypt_msg(encMessage=Txt, user_password=password) | |
| return encMessage | |
| #result_button_encrypt = gr.Button('Encrypt') | |
| #result_button_encrypt.click(greet, inputs = "text", outputs = "text") | |
| #iface = gr.Interface(fn=greet, inputs="text", outputs="text") | |
| #iface.launch() | |
| with gr.Blocks() as demo: | |
| #gr.Markdown("<h1><center> Message Encryption</center></h1>") | |
| gr.Markdown("<center> Encrypt your message and let your friends decrypt it on the same day.</center>") | |
| #gr.Markdown("<center> The one day limit is to enhance the privacy of the encrypted messages.</center>") | |
| #gr.Markdown("<center><b>'You can encrypt/decrypt so many messages everyday.'</b></center>") | |
| #gr.Markdown("<center>Transcription takes 5-10 seconds per minute of the video (bad audio/hard accents slow it down a bit). #patience<br />If you have time while waiting, drop a ♥️ and check out my <a href=https://www.artificial-intelligence.blog target=_blank>AI blog</a> (opens in new tab).</center>") | |
| input_text = gr.Textbox(placeholder='Message/ رسالة',label='') | |
| Passwrd = gr.Textbox(placeholder='Password (optional/ اختياري)',label='') | |
| #User_password = gr.Textbox(placeholder='Password', label='User password') | |
| result_button_encrypt = gr.Button('Encrypt/تشفير ') | |
| result_button_decrypt = gr.Button('Decrypt/فك تشفير') | |
| #vc_f0method = gr.Radio(label="Encrypt or Decrypt", choices=["Encrypt", "Decrypt"],value="Encrypt",interactive=True,) | |
| output_text = gr.Textbox(placeholder='Output', label='') | |
| inputs = [input_text, Passwrd] | |
| #gr.Textbox(placeholder='Message', label='Message'), | |
| #gr.Textbox(placeholder='Password', label='Password')] | |
| result_button_encrypt.click(Encrypt_users_txt, inputs = inputs, outputs = output_text) | |
| result_button_decrypt.click(Decrypt_users_txt, inputs = inputs, outputs = output_text) | |
| demo.queue(default_enabled = True).launch(debug = True) |