Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,7 +47,7 @@ def encrypt(passw=None,mes=None,img=None,doc=None):
|
|
| 47 |
enc_mes = f'{enc_mes}{im_bytes}+bbb+'
|
| 48 |
else:
|
| 49 |
enc_mes = f'{im_bytes}+bbb+'
|
| 50 |
-
|
| 51 |
if doc != None:
|
| 52 |
|
| 53 |
print(dir(doc))
|
|
@@ -70,8 +70,8 @@ def encrypt(passw=None,mes=None,img=None,doc=None):
|
|
| 70 |
enc_file=f'{doc.name}.ocrpt'
|
| 71 |
with open(enc_file, "wb") as file:
|
| 72 |
file.write(enc_doc)
|
| 73 |
-
|
| 74 |
-
return enc_mes,enc_file
|
| 75 |
|
| 76 |
def decrypt(passw=None,enc_in=None):
|
| 77 |
key = create_key(passw)
|
|
@@ -144,13 +144,17 @@ def decode_doc(passw=None,doc=None):
|
|
| 144 |
with gr.Blocks() as app:
|
| 145 |
with gr.Tab("Encrypt"):
|
| 146 |
pass_in=gr.Textbox(label="Set Password")
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
| 151 |
en_btn = gr.Button("Encrypt")
|
| 152 |
enc_out = gr.Textbox(label="Encrypted Bytes")
|
| 153 |
-
|
|
|
|
| 154 |
with gr.Tab("Decrypt"):
|
| 155 |
pass_out = gr.Textbox(label="Enter Password")
|
| 156 |
with gr.Tab("String"):
|
|
@@ -164,7 +168,7 @@ with gr.Blocks() as app:
|
|
| 164 |
dec_doc_btn = gr.Button("Decrypt")
|
| 165 |
dec_doc_out=gr.File()
|
| 166 |
dec_doc_btn.click(decode_doc,[pass_out,dec_doc_in],dec_doc_out)
|
| 167 |
-
en_btn.click(encrypt,[pass_in,mes,im,doc],[enc_out,enc_doc_out])
|
| 168 |
d_btn.click(decrypt,[pass_out,enc_in],[d_im,d_txt])
|
| 169 |
app.launch()
|
| 170 |
|
|
|
|
| 47 |
enc_mes = f'{enc_mes}{im_bytes}+bbb+'
|
| 48 |
else:
|
| 49 |
enc_mes = f'{im_bytes}+bbb+'
|
| 50 |
+
enc_qr = qr.make_qr(data=enc_mes)
|
| 51 |
if doc != None:
|
| 52 |
|
| 53 |
print(dir(doc))
|
|
|
|
| 70 |
enc_file=f'{doc.name}.ocrpt'
|
| 71 |
with open(enc_file, "wb") as file:
|
| 72 |
file.write(enc_doc)
|
| 73 |
+
|
| 74 |
+
return enc_mes,enc_file,enc_qr
|
| 75 |
|
| 76 |
def decrypt(passw=None,enc_in=None):
|
| 77 |
key = create_key(passw)
|
|
|
|
| 144 |
with gr.Blocks() as app:
|
| 145 |
with gr.Tab("Encrypt"):
|
| 146 |
pass_in=gr.Textbox(label="Set Password")
|
| 147 |
+
with gr.Tab("String"):
|
| 148 |
+
mes = gr.Textbox(label = "Message")
|
| 149 |
+
with gr.Row():
|
| 150 |
+
im = gr.Image(type="filepath")
|
| 151 |
+
doc=gr.File()
|
| 152 |
+
with gr.Tab("File"):
|
| 153 |
+
enc_doc_out=gr.File()
|
| 154 |
en_btn = gr.Button("Encrypt")
|
| 155 |
enc_out = gr.Textbox(label="Encrypted Bytes")
|
| 156 |
+
enc_qr_out = gr.Image("Encrypted QR")
|
| 157 |
+
|
| 158 |
with gr.Tab("Decrypt"):
|
| 159 |
pass_out = gr.Textbox(label="Enter Password")
|
| 160 |
with gr.Tab("String"):
|
|
|
|
| 168 |
dec_doc_btn = gr.Button("Decrypt")
|
| 169 |
dec_doc_out=gr.File()
|
| 170 |
dec_doc_btn.click(decode_doc,[pass_out,dec_doc_in],dec_doc_out)
|
| 171 |
+
en_btn.click(encrypt,[pass_in,mes,im,doc],[enc_out,enc_doc_out,enc_qr_out])
|
| 172 |
d_btn.click(decrypt,[pass_out,enc_in],[d_im,d_txt])
|
| 173 |
app.launch()
|
| 174 |
|