Update app.py
Browse files
app.py
CHANGED
@@ -30,8 +30,14 @@ def load_public_key_from_file(file_path):
|
|
30 |
def verify_signature(public_key, data, signature):
|
31 |
"""
|
32 |
Verify a signature with a public key.
|
|
|
33 |
"""
|
|
|
|
|
|
|
|
|
34 |
try:
|
|
|
35 |
public_key.verify(
|
36 |
signature,
|
37 |
data,
|
@@ -44,7 +50,7 @@ def verify_signature(public_key, data, signature):
|
|
44 |
return True
|
45 |
except Exception as e:
|
46 |
print("Verification failed:", e)
|
47 |
-
|
48 |
|
49 |
public_key = load_public_key_from_file("./nsfwais.pubkey.pem")
|
50 |
def swap_face(source_file, target_file, doFaceEnhancer, skey):
|
|
|
30 |
def verify_signature(public_key, data, signature):
|
31 |
"""
|
32 |
Verify a signature with a public key.
|
33 |
+
Converts the data to bytes if it's not already in byte format.
|
34 |
"""
|
35 |
+
# Ensure the data is in bytes. If it's a string, encode it to UTF-8.
|
36 |
+
if isinstance(data, str):
|
37 |
+
data = data.encode('utf-8')
|
38 |
+
|
39 |
try:
|
40 |
+
# Verify the signature
|
41 |
public_key.verify(
|
42 |
signature,
|
43 |
data,
|
|
|
50 |
return True
|
51 |
except Exception as e:
|
52 |
print("Verification failed:", e)
|
53 |
+
return False
|
54 |
|
55 |
public_key = load_public_key_from_file("./nsfwais.pubkey.pem")
|
56 |
def swap_face(source_file, target_file, doFaceEnhancer, skey):
|