C 语言部分
// func.c
char func(char a, char b) {
return (a ^ ((a % 17 + b) ^ 0x19));
}
编译
cc -fPIC -shared -o func.so func.c
调用
from ctypes import *
so_file = "./func.so"
lib = CDLL(so_file)
# call as
lib.func(1, 2) & 0xff # char 返回类型被符号扩展了
// func.c
char func(char a, char b) {
return (a ^ ((a % 17 + b) ^ 0x19));
}
cc -fPIC -shared -o func.so func.c
from ctypes import *
so_file = "./func.so"
lib = CDLL(so_file)
# call as
lib.func(1, 2) & 0xff # char 返回类型被符号扩展了