|
@@ -1,5 +1,5 @@
|
|
|
import ctypes
|
|
|
-
|
|
|
+import requests
|
|
|
# 根据实际情况修改签名验签库名称
|
|
|
SIGN_LIB_NAME = 'libgmsign.so'
|
|
|
VERIFY_LIB_NAME = 'libgmsign.so'
|
|
@@ -52,6 +52,32 @@ def verify_sign(raw_data: str, sign_data: str, public_key: str) -> bool:
|
|
|
verify_result = lib.sign_verify(content, sign_value, public_key)
|
|
|
verify_result = True if verify_result == 1 else False
|
|
|
return verify_result
|
|
|
+
|
|
|
+# 远程调用方式的签名验签接口
|
|
|
+# SIGN_API_URL = "http://api.example.com/sign"
|
|
|
+# VERIFY_API_URL = "http://api.example.com/verify"
|
|
|
+# def remote_sign(raw_data: str):
|
|
|
+# payload = {"raw_data": raw_data}
|
|
|
+# response = requests.post(SIGN_API_URL, json=payload)
|
|
|
+# if response.status_code == 200:
|
|
|
+# data = response.json()
|
|
|
+# return data['sign_data'], data['public_key']
|
|
|
+# else:
|
|
|
+# print("签名失败:", response.text)
|
|
|
+# return None, None
|
|
|
+
|
|
|
+# def remote_verify(raw_data: str, sign_data: str, public_key: str):
|
|
|
+# payload = {
|
|
|
+# "raw_data": raw_data,
|
|
|
+# "sign_data": sign_data,
|
|
|
+# "public_key": public_key
|
|
|
+# }
|
|
|
+# response = requests.post(VERIFY_API_URL, json=payload)
|
|
|
+# if response.status_code == 200:
|
|
|
+# return response.json().get("verify_result", False)
|
|
|
+# else:
|
|
|
+# print("验签失败:", response.text)
|
|
|
+# return False
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|