Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -89,16 +89,30 @@ def encrypt_text1(data,in2,address):
|
|
| 89 |
ciphertext, tag = cipher_aes.encrypt_and_digest(data)
|
| 90 |
[ file_out.write(x) for x in (enc_session_key, cipher_aes.nonce, tag, ciphertext) ]
|
| 91 |
file_out.close()
|
| 92 |
-
|
| 93 |
-
#
|
| 94 |
-
#
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
#output1 = pickle.dumps(output)
|
| 101 |
-
enc_qr = stegan2.conv_im(qr_link=address,data=out_file)
|
| 102 |
|
| 103 |
#out = output
|
| 104 |
#output.close()
|
|
@@ -149,10 +163,12 @@ def decrypt_text1(im,in2):
|
|
| 149 |
#[ file_out.write(x) for x in (mes_bytes1, mes_bytes2, mes_bytes3, mes_bytes4) ]
|
| 150 |
#file_out.close()
|
| 151 |
|
| 152 |
-
|
| 153 |
-
|
|
|
|
|
|
|
| 154 |
|
| 155 |
-
file_in = open("
|
| 156 |
|
| 157 |
private_key = RSA.import_key(open("private.pem").read())
|
| 158 |
enc_in=enc_in.strip('"')
|
|
|
|
| 89 |
ciphertext, tag = cipher_aes.encrypt_and_digest(data)
|
| 90 |
[ file_out.write(x) for x in (enc_session_key, cipher_aes.nonce, tag, ciphertext) ]
|
| 91 |
file_out.close()
|
| 92 |
+
################################
|
| 93 |
+
#doc_name = doc.name
|
| 94 |
+
#doc_name = doc_name.split("/",4)[4]
|
| 95 |
+
doc_name = "encrypted_data.bin"
|
| 96 |
+
with open(doc.name, "rb") as file:
|
| 97 |
+
# read all file data
|
| 98 |
+
file_data = file.read()
|
| 99 |
+
qr_link="test"
|
| 100 |
+
enc_qr = stegan2.conv_im(qr_link=qr_link,data=enc_mes)
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
#enc_doc = fernet.encrypt(file_data)
|
| 104 |
+
#og_name = doc.name
|
| 105 |
+
#og_end = og_name.split(".",1)[1]
|
| 106 |
+
#og_front=og_name.split(".",1)[0]
|
| 107 |
|
| 108 |
|
| 109 |
+
#enc_file=f'{doc.name}.ocrpt'
|
| 110 |
+
#with open(enc_file, "wb") as file:
|
| 111 |
+
# file.write(enc_doc)
|
| 112 |
+
########################################
|
| 113 |
+
|
| 114 |
#output1 = pickle.dumps(output)
|
| 115 |
+
#enc_qr = stegan2.conv_im(qr_link=address,data=out_file)
|
| 116 |
|
| 117 |
#out = output
|
| 118 |
#output.close()
|
|
|
|
| 163 |
#[ file_out.write(x) for x in (mes_bytes1, mes_bytes2, mes_bytes3, mes_bytes4) ]
|
| 164 |
#file_out.close()
|
| 165 |
|
| 166 |
+
enc_in = stegan2.decode(im)
|
| 167 |
+
with open("encrypted_data1.bin", "wb") as file:
|
| 168 |
+
file.write(enc_in)
|
| 169 |
+
file.close()
|
| 170 |
|
| 171 |
+
file_in = open("encrypted_data1.bin", "rb")
|
| 172 |
|
| 173 |
private_key = RSA.import_key(open("private.pem").read())
|
| 174 |
enc_in=enc_in.strip('"')
|