Explorar o código

修改签名验签流程

liyan hai 11 meses
pai
achega
1f022c1a6f
Modificáronse 1 ficheiros con 5 adicións e 2 borrados
  1. 5 2
      tests/sign_verify.py

+ 5 - 2
tests/sign_verify.py

@@ -1,5 +1,8 @@
 import ctypes
 
+SIGN_LIB_NAME = 'libgmsign.so'
+VERIFY_LIB_NAME = 'libgmsign.so'
+
 def get_sign(raw_data: str) -> (str, str):
     """
     获取签名值
@@ -7,7 +10,7 @@ def get_sign(raw_data: str) -> (str, str):
     :return: tuple(str,str):(签名值base64字符串,公钥base64字符串)
     """
     # 加载共享库
-    lib = ctypes.CDLL('libgmsign.so')
+    lib = ctypes.CDLL(SIGN_LIB_NAME)
 
     # 定义函数的参数和返回类型
     # 签名函数签名如下:
@@ -36,7 +39,7 @@ def verify_sign(raw_data: str, sign_data: str, public_key: str) -> bool:
     :return:
     """
     # 加载共享库
-    lib = ctypes.CDLL('libgmsign.so')
+    lib = ctypes.CDLL(VERIFY_LIB_NAME)
     # 验签函数签名如下:
     # int sign_verify(char *content, char *sign_value, char *public_key)
     lib.sign_verify.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p]