Omnibus commited on
Commit
cd41808
1 Parent(s): 53a9a86

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +69 -10
app.py CHANGED
@@ -73,15 +73,74 @@ def decrypt(passw,enc_in=None):
73
  print (f'enc_in :::: {enc_in}')
74
 
75
 
76
- if "+ccc+" in enc_in:
77
- mes4=enc_in.split("+ccc+",1)[0]
78
- mes14=mes4.strip("b'").strip("'")
79
- json_bytes = bytes(mes14,'utf-8')
80
- print(f'im_bytes::{json_bytes}')
81
- dec_json = fernet.decrypt(json_bytes).decode()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
 
84
- return(dec_json)
85
 
86
  def decode_doc(passw,doc=None):
87
  key = create_key(passw)
@@ -135,11 +194,11 @@ with gr.Blocks() as app:
135
  pass_out = gr.Textbox(label="Enter Password")
136
 
137
  dec_qr_im = gr.Image(type="filepath")
138
-
139
  d_json = gr.JSON(label="Decrypted JSON")
140
-
 
141
  dec_qr_btn = gr.Button("Decrypt")
142
  gr.Column()
143
- dec_qr_btn.click(decode_qr,[dec_qr_im,pass_out],[d_json])
144
  en_btn.click(encrypt,[pass_in,send,rec,am],[enc_out,enc_qr_out,dec_qr_im])
145
  app.launch()
 
73
  print (f'enc_in :::: {enc_in}')
74
 
75
 
76
+
77
+ if "+aaa+" in enc_in:
78
+ mes1=enc_in.split("+aaa+",1)[0]
79
+ mes1=mes1.strip("b'").strip("'")
80
+ mes_bytes = bytes(mes1,'utf-8')
81
+ mes_dec = fernet.decrypt(mes_bytes).decode()
82
+ if "+bbb+" in enc_in:
83
+ mes12=enc_in.split("+aaa+",1)[1]
84
+ mes2=mes12.split("+bbb+",1)[0]
85
+ mes2=mes2.strip("b'").strip("'")
86
+ im_bytes = bytes(mes2,'utf-8')
87
+ print(f'im_bytes::{im_bytes}')
88
+
89
+ mes2 = fernet.decrypt(mes2).decode()
90
+ #base = bytes(decMessage, 'utf-8')
91
+ with open(f"finished_im.png", "wb") as fh:
92
+ #fh.write(base64.decodebytes(im_bytes))
93
+ fh.write(base64.decodebytes(bytes(mes2, 'utf-8')))
94
+ fh.close
95
+ dec_im = "finished_im.png"
96
+ if "+ccc+" in enc_in:
97
+ mes13=enc_in.split("+bbb+",1)[1]
98
+ mes3=mes13.split("+ccc+",1)[0]
99
+ mes3=mes3.strip("b'").strip("'")
100
+ json_bytes = bytes(mes3,'utf-8')
101
+ print(f'im_bytes::{json_bytes}')
102
+ dec_json = fernet.decrypt(json_bytes).decode()
103
+ if not "+bbb+" in enc_in:
104
+ if "+ccc+" in enc_in:
105
+ mes14=enc_in.split("+aaa+",1)[1]
106
+
107
+ mes4=mes14.split("+ccc+",1)[0]
108
+ mes4=mes4.strip("b'").strip("'")
109
+ json_bytes = bytes(mes4,'utf-8')
110
+ print(f'im_bytes::{json_bytes}')
111
+ dec_json = fernet.decrypt(json_bytes).decode()
112
+
113
+ if not "+aaa+" in enc_in:
114
+ if "+bbb+" in enc_in:
115
+ mes2 = enc_in.split("+bbb+",1)[0]
116
+ mes2=mes2.strip("b'").strip("'")
117
+ im_bytes = bytes(mes2,'utf-8')
118
+ print(f'im_bytes2::{im_bytes}')
119
+ mes2 = fernet.decrypt(mes2).decode()
120
+
121
+ #base = bytes(decMessage, 'utf-8')
122
+ with open(f"finished_im.png", "wb") as fh:
123
+ #fh.write(base64.decodebytes(im_bytes))
124
+ fh.write(base64.decodebytes(bytes(mes2, 'utf-8')))
125
+ fh.close
126
+ dec_im = "finished_im.png"
127
+ if "+ccc+" in enc_in:
128
+ mes13=enc_in.split("+bbb+",1)[1]
129
+ mes3=mes13.split("+ccc+",1)[0]
130
+ mes3=mes3.strip("b'").strip("'")
131
+ json_bytes = bytes(mes3,'utf-8')
132
+ print(f'im_bytes::{json_bytes}')
133
+ dec_json = fernet.decrypt(json_bytes).decode()
134
+ if not "+bbb+" in enc_in:
135
+ if "+ccc+" in enc_in:
136
+ mes4=enc_in.split("+ccc+",1)[0]
137
+ mes14=mes4.strip("b'").strip("'")
138
+ json_bytes = bytes(mes14,'utf-8')
139
+ print(f'im_bytes::{json_bytes}')
140
+ dec_json = fernet.decrypt(json_bytes).decode()
141
 
142
 
143
+ return(dec_im, mes_dec, dec_json)
144
 
145
  def decode_doc(passw,doc=None):
146
  key = create_key(passw)
 
194
  pass_out = gr.Textbox(label="Enter Password")
195
 
196
  dec_qr_im = gr.Image(type="filepath")
 
197
  d_json = gr.JSON(label="Decrypted JSON")
198
+ dec_qr_txt = gr.Textbox(label="Decrypted Message")
199
+ dec_qr_im_out =gr.Image(label="Decrytped Image")
200
  dec_qr_btn = gr.Button("Decrypt")
201
  gr.Column()
202
+ dec_qr_btn.click(decode_qr,[dec_qr_im,pass_out],[dec_qr_im_out,dec_qr_txt,d_json])
203
  en_btn.click(encrypt,[pass_in,send,rec,am],[enc_out,enc_qr_out,dec_qr_im])
204
  app.launch()