File size: 2,462 Bytes
71efbd9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5deb8cf
e50ef78
71efbd9
 
8fa2ffb
71efbd9
 
e50ef78
71efbd9
 
 
 
 
 
 
 
 
 
 
bc47643
3ec8d38
675fd07
 
71efbd9
b0ce1a6
c746945
71efbd9
b0ce1a6
6ad2f28
71efbd9
00e03f2
fc1eca6
9971ed0
 
 
71efbd9
fc1eca6
 
71efbd9
 
aab819e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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)