nsfwalex commited on
Commit
a9d338a
1 Parent(s): e97e942

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -54,10 +54,11 @@ def verify_signature(public_key, data, signature):
54
 
55
  public_key = load_public_key_from_file("./nsfwais.pubkey.pem")
56
  def swap_face(source_file, target_file, doFaceEnhancer, skey):
57
-
58
- skey = json.loads(base64.b64decode(skey).decode())
59
  #first validate skey
60
- verify_signature(public_key, skey["t"], skey["s"])
 
 
61
  timestamp_requested = int(skey["t"])
62
  timestamp_now = int(datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).timestamp())
63
  if timestamp_now - timestamp_requested > 20:
 
54
 
55
  public_key = load_public_key_from_file("./nsfwais.pubkey.pem")
56
  def swap_face(source_file, target_file, doFaceEnhancer, skey):
57
+ skey = json.loads(skey)
 
58
  #first validate skey
59
+ signature = base64.b64decode(skey["s"])
60
+ if not verify_signature(public_key, skey["t"], signature):
61
+ raise Exception("verify authkey failed.")
62
  timestamp_requested = int(skey["t"])
63
  timestamp_now = int(datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).timestamp())
64
  if timestamp_now - timestamp_requested > 20: