File size: 901 Bytes
0d277e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import hashlib
import gradio as gr
css = """
footer {visibility: hidden}
"""


def check(original_image, verified_image):
    # Compute the hash code of the original image
    original_hash = hashlib.sha256(original_image).hexdigest()

    # Compute the hash code of the image to be verified
    verified_hash = hashlib.sha256(verified_image).hexdigest()

    # Compare the two hash codes
    if original_hash == verified_hash:
        result = "The image is authentic."
        return result, original_hash, verified_hash
    else:
        result = "The image has been modified or corrupted."
        return result, original_hash, verified_hash

iface = gr.Interface(fn=check, inputs=["image", "image"], outputs=["text", "text", "text"],
                     title="Image Hash Checker", description="Check if an image has been modified or corrupted.",
                     css=css, )

iface.launch()