企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## 示例 go 代码 <details> <summary>pgp.go</summary> ``` package main import "C" import ( "fmt" "github.com/ProtonMail/gopenpgp/v2/helper" ) // put keys in backtick (``) to avoid errors caused by spaces or tabs const pubkey = `-----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v2.0.22 (GNU/Linux) mQENBGO2c0ABCADq4cKbunJlzR/lEfQ3NUURT/hFYdvN5zl697RBZG0pLw0OK9jk KuMJ0/gLscgS1uSaUfU3kghjQTHmqMSXgPAhio4LqthEym5xFOiOuC1i/6bXt20z 2fb+hrq7FSky9Q33wraEOBp0ojLc1mBzJ+FkklD4K0BrglW8ykYo+mucvexBJE/+ zTlY1fNWob5r3XL+A7RfrK4xGzT5FLP7GYKOLdNflzmjtSJLbETPFbvzWowk8PNL XoCWziYVZCephjNRwFaI5ZTTIQKiWpAcIWeQTCzEpD/L30yyldmjtQP846rqgzrc PfPtexfaapvk2To8/8tdc1l6tDl+pSo3ScnrABEBAAG0I2JpZ2FudC5jbiAobm9u ZSkgPGJpZ2FudEBiaWdhbnQuY24+iQE5BBMBAgAjBQJjtnNAAhsDBwsJCAcDAgEG FQgCCQoLBBYCAwECHgECF4AACgkQ5/ZYAQdME679kgf+O1OR1S820fTippTsmf0N b6FFRPJcacni3ciquRy25Uc6z5C/Bvxk6cjYYhWXgFAJjUZUo0rpTxABDBzmg8SY 8UCcz9sz4eLG7wvkLE2PuHqYPveoBv9s00/Vn18Z8lLdvvigJZiNKnouIt/E8NxG LPCpMNWiNFuFAMP92wR6UqA6Fael0qK+6nwPVCOFR2I0vmGUxn1sRLvQKznwYvcd xKo3fIlfCTbMf171imPmGLuUneMAwObmBG9Oaldmvgao96LW3EVloUu/ijrHSzDA An1TAhRMe4j4MlrjwSQ7gMDR1ALMBzBGNugsB05sMiVlXxHpENSBbPvwgdyCiKv4 zrkBDQRjtnNAAQgAzXCz1MlWaYKFvjN6Pq24rCrEBWAlWJaLK8gVVOr5eKJ22TlZ L6q2lllVdC0szb4NW0vGIFLURelgKEVjlXJ7K5dPDAdVlrNWh69K9vJZkAamQZsz Edfoj5Lpi8wZdRPHdL28d7Zu4RwtJm6dBUw3BfqXhJQ6X9qgLdnYYx2Sy/dQeBWK GR0sFRscSkmmUSW1vGwAo4LNYz56u1OZKL65OzNJxiJH07uhrKsbeiG1Tu4IQItm LjBAmQEdW3wCMN5oYIllnnOoJdaBgThRx2FJIqlM4FtmaUnB+NAOq2rGc+kufpeC W4cgrKEIoa+0MZ6L2yA2WGGfJWAfJyq0cq7miQARAQABiQEfBBgBAgAJBQJjtnNA AhsMAAoJEOf2WAEHTBOuBV4H/jLJttR3w1vO+PyHRmmrL/RsO03KiBT/pE7HMLyM MWWCoaZiFTzdH034VjvccMR23nhZwENVYk1CQubZONX1ME8OThOVzSc1oqivTgQz u91NtYgo5G6fOhB6oU7ZRcbt3iBsFHkv+24TRdsH5DbXyPVgUpTFs8meN0ydssi+ Y8ufV2SCJ31tVdPL8NCA2vLHYHhdagiucOpY0IPtRIDiQ6QQDiXoZRPQtoWr/8b2 XQNu8mMNfj+gYEPb98ekr5vYVk74TwMxlHUy6KlDxLpjkuu3avZORM11pZWsaP3j G5Yzq5kBFlMgmPoIZM3B4nez/BN6JIyvU3pwr5HPHFyKaUs= =E3yx -----END PGP PUBLIC KEY BLOCK----- ` const privkey = `-----BEGIN PGP PRIVATE KEY BLOCK----- Version: GnuPG v2.0.22 (GNU/Linux) lQO+BGO2c0ABCADq4cKbunJlzR/lEfQ3NUURT/hFYdvN5zl697RBZG0pLw0OK9jk KuMJ0/gLscgS1uSaUfU3kghjQTHmqMSXgPAhio4LqthEym5xFOiOuC1i/6bXt20z 2fb+hrq7FSky9Q33wraEOBp0ojLc1mBzJ+FkklD4K0BrglW8ykYo+mucvexBJE/+ zTlY1fNWob5r3XL+A7RfrK4xGzT5FLP7GYKOLdNflzmjtSJLbETPFbvzWowk8PNL XoCWziYVZCephjNRwFaI5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vlxN+XdLRQn yrWgpCAfGIQIuWQ8jT568rHBe8CrOqOtGGELQAmV++llFawnTz0Y7qb+b0pNctFx +lvrLl7JEynILvXYfSBOnx3MKvrPXuemyYw8RaG5+xZI3qAdsvwEaBaebKzFgVxK 8KOUrqeTIp92qCkY1rkXQBzpzAVFj+ubqOmTMeOBBRlR0ywmJRaQFnj01UEzjtFm 4+LRS4qp32JtUKLSouvSjmIz/XyD51+fYqvnFHRk50Og63hmQN2jpDQh6jQ4Z2+2 DeGhVfsLBn/FwT91KYSBgja42nGop70zxGgYiVXwQUpSSAgOK7gTJK4zoMJM4GHe HprnbrbK1J3VjTYqyW0xYIe8moPbmDDsnCg2dQuPVlxMw1xHkhxQyARovNcDgssJ Qe12L+F23Cf3UDHkW1f5HOQOmKbZ4PJUDkNCoxa51wz61TMajh1Q5UtOmDRGgmTl ahAPEuN0XVugbe5gGf+IZgY+18wvGUZ0OZWG7fCz1Cp2474P3q2kPiEdGGsDEPT0 vvsKT3fn2DI4U/ngS/8/S78N+AXBRU7ffieEqsMKs49fTOE2rYVujW/8msOHtV0S izUZGPZKTJ+CU7qh3569NgeP2YkBHwQYAQIACQUCY7ZzQAIbDAAKCRDn9lgBB0wT rgVeB/4yybbUd8Nbzvj8h0Zpqy/0bDtNyogU/6ROxzC8jDFlgqGmYhU83R9N+FY7 3HDEdt54WcBDVWJNQkLm2TjV9TBPDk4Tlc0nNaKor04EM7vdTbWIKORunzoQeqFO 2UXG7d4gbBR5L/tuE0XbB+Q218j1YFKUxbPJnjdMnbLIvmPLn1dkgid9bVXTy/DQ gNryx2B4XWoIrnDqWNCD7USA4kOkEA4l6GUT0LaFq//G9l0DbvJjDX4/oGBD2/fH pK+b2FZO+E8DMZR1MuipQ8S6Y5Lrt2r2TkTNdaWVrGj94xuWM6uZARZTIJj6CGTN weJ3s/wTeiSMr1N6cK+RzxxcimlL =IF1G -----END PGP PRIVATE KEY BLOCK-----` // encrypted private key var passphrase = []byte(`bigant.cn`) // Passphrase of the privKey // 必须声明 func main() { with_key() } func with_signa() { // encrypt message using public key, sign with the private key armor, err := helper.EncryptSignMessageArmored(pubkey, privkey, passphrase, "plain text") if err != nil { panic(err) } fmt.Printf("armor %+v\n", armor) // decrypt armored encrypted message using the private key, verify with the public key // err != nil if verification fails decrypted, err := helper.DecryptVerifyMessageArmored(pubkey, privkey, passphrase, armor) if err != nil { panic(err) } fmt.Printf("decrypted %+v\n", decrypted) } func with_key() { // encrypt plain text message using public key armor, err := helper.EncryptMessageArmored(pubkey, "plain text") if err != nil { panic(err) } fmt.Printf("加密后的值:%+v\n", armor) // decrypt armored encrypted message using the private key and obtain plain text decrypted, err := helper.DecryptMessageArmored(privkey, passphrase, armor) if err != nil { panic(err) } fmt.Printf("解密后的值:%+v\n", decrypted) // encrypt binary message using public key armor2, err := helper.EncryptBinaryMessageArmored(pubkey, []byte("plain text")) if err != nil { panic(err) } fmt.Printf("加密后的二进制:%+v\n", armor2) // decrypt armored encrypted message using the private key expecting binary data decrypted2, err := helper.DecryptBinaryMessageArmored(privkey, passphrase, armor) if err != nil { panic(err) } fmt.Printf("解密后的值%+v\n", decrypted2) } // 只常识导出 encrypt_key 和 decrypt_key //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)) } ``` </details> <br/> window ``` go build -o pgp.dll -buildmode=c-shared pgp.go ``` linux ``` go build -o pgp.so -buildmode=c-shared pgp.go ``` 会生成一个pgp.h 的头文件和pgp.dll > 注意 c-shared 不能使用交叉编译 > window 和linux 生成的头文件有差别 在c++ 引入 ``` // ConsoleApplication1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <iostream> #include "pgp.h" //#pragma comment(lib,"pgp.lib") int main() { GoString pubk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w3BfqXhJQ6X9qgLdnYYx2Sy/dQeBWK\nGR0sFRscSkmmUSW1vGwAo4LNYz56u1OZKL65OzNJxiJH07uhrKsbeiG1Tu4IQItm\nLjBAmQEdW3wCMN5oYIllnnOoJdaBgThRx2FJIqlM4FtmaUnB+NAOq2rGc+kufpeC\nW4cgrKEIoa+0MZ6L2yA2WGGfJWAfJyq0cq7miQARAQABiQEfBBgBAgAJBQJjtnNA\nAhsMAAoJEOf2WAEHTBOuBV4H/jLJttR3w1vO+PyHRmmrL/RsO03KiBT/pE7HMLyM\nMWWCoaZiFTzdH034VjvccMR23nhZwENVYk1CQubZONX1ME8OThOVzSc1oqivTgQz\nu91NtYgo5G6fOhB6oU7ZRcbt3iBsFHkv+24TRdsH5DbXyPVgUpTFs8meN0ydssi+\nY8ufV2SCJ31tVdPL8NCA2vLHYHhdagiucOpY0IPtRIDiQ6QQDiXoZRPQtoWr/8b2\nXQNu8mMNfj+gYEPb98ekr5vYVk74TwMxlHUy6KlDxLpjkuu3avZORM11pZWsaP3j\nG5Yzq5kBFlMgmPoIZM3B4nez/BN6JIyvU3pwr5HPHFyKaUs=\n=E3yx\n-----END PGP PUBLIC KEY BLOCK-----",1751 }; GoSlice plainText = { (char*)"message221232131232",54,54}; char* ret = encrypt_key(pubkey, plainText); printf("%s\n", ret); GoString prikey = { "-----BEGIN PGP PRIVATE KEY BLOCK-----\nVersion: GnuPG v2.0.22 (GNU/Linux)\n\nlQO+BGO2c0ABCADq4cKbunJlzR/lEfQ3NUURT/hFYdvN5zl697RBZG0pLw0OK9jk\nKuMJ0/gLscgS1uSaUfU3kghjQTHmqMSXgPAhio4LqthEym5xFOiOuC1i/6bXt20z\n2fb+hrq7FSky9Q33wraEOBp0ojLc1mBzJ+FkklD4K0BrglW8ykYo+mucvexBJE/+\nzTlY1fNWob5r3XL+A7RfrK4xGzT5FLP7GYKOLdNflzmjtSJLbETPFbvzWowk8PNL\nXoCWziYVZCephjNRwFaI5ZTTIQKiWpAcIWeQTC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=IF1G\n-----END PGP PRIVATE KEY BLOCK-----\n",3649 }; GoSlice passphrase = { (char*)"bigant.cn",9,9 }; GoString ciphertext = { ret, 50}; //GoString ciphertext = { "-----BEGIN PGP MESSAGE-----\nVersion: GopenPGP 2.5.0\nComment: https://gopenpgp.org\n\nwcBMAydR4mIk/KkaAQf+OpAhjJFH8pzNgOc62QB1HejPIu2Rt34MZvdZG/tyfhNN\n5GydKCS8uTYCFr6EtronBUJ5qNHZX+no8zhbng/vmK8ddLSF5UcoLeo65pmhH0f+\nPNFAG2iU9m2SPkJFYy5QGkkGCo1AdYckjxli8+p9ene/Kz+KsISX5P/p+dpCDSik\nm53HTRfmjrph7O1Xzy8GKUH7h6JAKaKBluPmsDAel+4hoYhBxORX1MiHRSsNUzyU\nOVWz7QK0KFrE75JiWtfcQAHoXAm8/Pb1USu4Ew6qtSIN4Jl0y2RKTqdbHRW9C4q9\nRZlK4o4ly7kE20vhVqxq/UDkMSadScLAvzEH/2VuDtI9Aa4zYgTFHnGieI7Rva9v\nQPJgXqukOfrSBsvMQgnF/2NPad29c3dfmky02M6BR3PKzk/KdJvSLPHbENte6Q==\n=hGB/\n-----END PGP MESSAGE-----", 581}; char* ret2 = decrypt_key(prikey, passphrase, ciphertext); printf("output :%s", ret2); } ``` widnow ``` g++ -o demo.exe demo.cpp -L. -lpgp ``` linux 把 pgp.so 改成 libpgp.so ``` g++ -o demo demo.cpp -L. -lpgp ```