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ZM6NZ/ppoy3MtSyP/pzZ2Gx4tC4sGjTYTp1qq8y77AIUIQqL3a2G/w6zr7KtSG+uE7D0eWHTfv9RaCoO2qm5/8qKshYarnyUx+Nzm0xZzpu8oL8EAqp8FUYztwAAAAAAAA=
不同的原文得到的签名结果开始都一样( MIAGCS ),文档原文说的 是签名使用己方私钥以 PKCS7 签名格式(不包含原文)生成,签名算法为 SHA256withRSA, 将字节数 组进行 Base64 编码转换为文本 但是我用 openssl_sign 签名出的结果完全不一样,大佬们知道在 php 里怎么得到这种签名么?
1
mzeht 2019-08-16 10:47:34 +08:00
对方是他的私钥 rsa 加密然后 base64 你需要 base64 解开 然后用你的公钥去 check 挺常规的
|
2
jay4497 2019-08-16 11:04:36 +08:00
建议使用 phpseclib 这个库,PHP 自带的有些加密好像不是很通用。。。
|