💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] ## C 示例 ``` //export encrypt_key func encrypt_key(pubkey string, plainText []byte) *C.char { ciphertext, _ := helper.EncryptBinaryMessageArmored(pubkey, plainText) return C.CString(ciphertext) } //export decrypt_key func decrypt_key(privateKey string, passphrase []byte, ciphertext string) *C.char { plaintext, _ := helper.DecryptBinaryMessageArmored(privateKey, passphrase, ciphertext) return C.CString(string(plaintext)) } ``` c 调用 ``` int main() { GoString pubkey={"abc",123}; GoSlice plainText={"my message22",12,12 }; char* ret= encrypt_key(pubkey,plainText); printf("%s\n",ret); GoString prikey = {"abc",123}; GoSlice passphrase = { "bigant.cn",9,9 }; GoString ciphertext = { ret, strlen(ret) }; char* ret2 =decrypt_key(prikey, passphrase, ciphertext); printf("解答:%s", ret2); return 0; } ``` 执行 gcc ``` gcc -o demo demo.c ./pgp.so && ./demo.exe ```