Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,10 @@ from Crypto.PublicKey import RSA
|
|
| 7 |
from Crypto.Cipher import PKCS1_OAEP
|
| 8 |
import binascii
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
import os
|
| 12 |
import base64
|
|
@@ -17,6 +21,10 @@ import qr
|
|
| 17 |
import stegan
|
| 18 |
import json
|
| 19 |
import re
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
eth_wal = gr.Interface.load("spaces/Omnibus/decentral-test-mod")
|
| 21 |
|
| 22 |
def rsa_encrypt_eth():
|
|
@@ -49,13 +57,24 @@ def rsa_generate():
|
|
| 49 |
pubcipher = PKCS1_OAEP.new(pubKey)
|
| 50 |
out1 = f'{pubKey.n}{keyPair.d}'
|
| 51 |
out2 = f'{pubKey.n}{keyPair.e}'
|
| 52 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
def rsa_encrypt(msg,pubKey):
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
print (pubKey)
|
| 57 |
msg = b'A message for encryption'
|
| 58 |
-
encryptor = PKCS1_OAEP.new(
|
| 59 |
encrypted = encryptor.encrypt(msg)
|
| 60 |
print("Encrypted:", binascii.hexlify(encrypted))
|
| 61 |
return binascii.hexlify(encrypted)
|
|
|
|
| 7 |
from Crypto.Cipher import PKCS1_OAEP
|
| 8 |
import binascii
|
| 9 |
|
| 10 |
+
from Crypto.PublicKey import RSA
|
| 11 |
+
from Crypto.Cipher import PKCS1_v1_5
|
| 12 |
+
from base64 import b64decode
|
| 13 |
+
|
| 14 |
|
| 15 |
import os
|
| 16 |
import base64
|
|
|
|
| 21 |
import stegan
|
| 22 |
import json
|
| 23 |
import re
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
|
| 28 |
eth_wal = gr.Interface.load("spaces/Omnibus/decentral-test-mod")
|
| 29 |
|
| 30 |
def rsa_encrypt_eth():
|
|
|
|
| 57 |
pubcipher = PKCS1_OAEP.new(pubKey)
|
| 58 |
out1 = f'{pubKey.n}{keyPair.d}'
|
| 59 |
out2 = f'{pubKey.n}{keyPair.e}'
|
| 60 |
+
return privKeyPEM,pubKeyPEM,output,"qr_wal_tmp.png",output
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
|
| 65 |
|
| 66 |
def rsa_encrypt(msg,pubKey):
|
| 67 |
+
|
| 68 |
+
key = b64decode(pubKey)
|
| 69 |
+
private_key = RSA.importKey(key)
|
| 70 |
+
cipher = PKCS1_v1_5.new(private_key)
|
| 71 |
+
cipher.encrypt(msg)
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
#pubKey=pubKey.encode("utf-8")
|
| 75 |
print (pubKey)
|
| 76 |
msg = b'A message for encryption'
|
| 77 |
+
encryptor = PKCS1_OAEP.new(cipher)
|
| 78 |
encrypted = encryptor.encrypt(msg)
|
| 79 |
print("Encrypted:", binascii.hexlify(encrypted))
|
| 80 |
return binascii.hexlify(encrypted)
|