Spaces:
Sleeping
Sleeping
Update tab/tab1to3_unified.py
Browse files- tab/tab1to3_unified.py +5 -6
tab/tab1to3_unified.py
CHANGED
|
@@ -48,17 +48,16 @@ def generate_qr_image(data):
|
|
| 48 |
# ---------------- QR Code Decoder ----------------
|
| 49 |
def decode_qr_image(pil_img):
|
| 50 |
img = cv2.cvtColor(np.array(pil_img), cv2.COLOR_RGB2BGR)
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
lines =
|
| 55 |
key_line = next((line for line in lines if line.startswith("Key: ")), None)
|
| 56 |
msg_line = next((line for line in lines if line.startswith("Message: ")), None)
|
| 57 |
key = key_line.replace("Key: ", "") if key_line else ""
|
| 58 |
msg = msg_line.replace("Message: ", "") if msg_line else ""
|
| 59 |
return msg, key
|
| 60 |
-
|
| 61 |
-
return "", ""
|
| 62 |
|
| 63 |
# ---------------- Encryption ----------------
|
| 64 |
def quantum_encrypt(message, qkd_key):
|
|
|
|
| 48 |
# ---------------- QR Code Decoder ----------------
|
| 49 |
def decode_qr_image(pil_img):
|
| 50 |
img = cv2.cvtColor(np.array(pil_img), cv2.COLOR_RGB2BGR)
|
| 51 |
+
detector = cv2.QRCodeDetector()
|
| 52 |
+
data, _, _ = detector.detectAndDecode(img)
|
| 53 |
+
if data:
|
| 54 |
+
lines = data.splitlines()
|
| 55 |
key_line = next((line for line in lines if line.startswith("Key: ")), None)
|
| 56 |
msg_line = next((line for line in lines if line.startswith("Message: ")), None)
|
| 57 |
key = key_line.replace("Key: ", "") if key_line else ""
|
| 58 |
msg = msg_line.replace("Message: ", "") if msg_line else ""
|
| 59 |
return msg, key
|
| 60 |
+
return "", ""
|
|
|
|
| 61 |
|
| 62 |
# ---------------- Encryption ----------------
|
| 63 |
def quantum_encrypt(message, qkd_key):
|