Update app.py
Browse files
app.py
CHANGED
|
@@ -41,14 +41,25 @@ def save_hash(hash_code, description=""):
|
|
| 41 |
# Function to check image authenticity
|
| 42 |
def check_authenticity(image):
|
| 43 |
hash_code = hash_image(image)
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
return "Image is new or modified."
|
| 51 |
|
|
|
|
| 52 |
def process_image(image, description):
|
| 53 |
hash_code1 = hash_image(image)
|
| 54 |
qr_img = generate_qr_code(hash_code1)
|
|
|
|
| 41 |
# Function to check image authenticity
|
| 42 |
def check_authenticity(image):
|
| 43 |
hash_code = hash_image(image)
|
| 44 |
+
try:
|
| 45 |
+
with open("hash.txt", "r") as file:
|
| 46 |
+
hashes = file.readlines()
|
| 47 |
+
for line in hashes:
|
| 48 |
+
parts = line.strip().split(': ', 1)
|
| 49 |
+
if len(parts) == 2:
|
| 50 |
+
saved_hash, description = parts
|
| 51 |
+
if saved_hash == hash_code:
|
| 52 |
+
return f"Image is authentic. Description: {description}"
|
| 53 |
+
else:
|
| 54 |
+
# Handle the case where there is no ':' or description
|
| 55 |
+
saved_hash = parts[0]
|
| 56 |
+
if saved_hash == hash_code:
|
| 57 |
+
return "Image is authentic, but no description provided."
|
| 58 |
+
except FileNotFoundError:
|
| 59 |
+
return "Hash file not found. Please process an image first."
|
| 60 |
return "Image is new or modified."
|
| 61 |
|
| 62 |
+
|
| 63 |
def process_image(image, description):
|
| 64 |
hash_code1 = hash_image(image)
|
| 65 |
qr_img = generate_qr_code(hash_code1)
|