Closed xiaoxin1 closed 7 years ago
这是generate出来的 -----BEGIN RSA PUBLIC KEY----- MIIBCgKCAQEAtv4b3uiZ95VbrmP1aHBa+dnCi1ji8zckQba5815A42DwKGZiDqwm Q7B9BAXKSWyCOCqRd8f39LYuz4fAPuIXWLwzjXkrdYv2wcvOr+8NpIQ05/Kwy8kt o3Pa3h3Q1Vw7ItWznnz28t6ejPrc0L1l3N/HkMrZnyH23x8FJ8o6k1FhBH28YpuC 9tg4KSbTiOnuHZ/TPnJ2hammRmFEKRpf1PV2lySjVrHXSAQ9+Sr4TwvQJGo9vWCx QjIvgoD06l8NvnLPu4lsYI8BAkMIsd5rzIp6XYyEHV88+wx6e/AmYf1P4Tkd9XZ3 d8NdWkMd8wJgzncrCnYhmBA/6Wm7orINhwIDAQAB -----END RSA PUBLIC KEY-----
这是我的: -----BEGIN RSA PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlKp7UqlyK65w6k3qH99W rp7xtiCNy1uHTX67nVadoOoMCDGXYJpdmQ8bZ3WQRPu0Xw9/s58c/F2BKLD+jAy9 mFZOyxfVCwgKww4mcKWwFApRG3tHwJaDdlm/iXQdpBB/X2mFk3CXmDNK086NXmJX cMqIQKMxmfbEqSSAIdKzLK4gNrakP2i4/tNZt2yDvv458EuY+BfB+qYFl0LjVS9m JoBbXH2dvRtljIrzw0906cPcd+8g/6va0j7beVKIICwrvqop1ziLF51KI5jF/fRf QlgUKMeypwxXhkBcEM6oqPkonutm/8XdPDTXki7+qsCWJNFI2puJkOmYWZ4uGbPQ hQIDAQAB -----END RSA PUBLIC KEY-----
用上面的new出来没问题,也可以正常加解密,用我的错误 new rsa err: wrong tag
看错误信息,你提供的公钥格式有问题?
没有问题的,我还试了和这个公钥能配对的私钥,私钥没问题
可否提供你的调用代码,以供我排查问题?
不好意思,确实是公私钥格式不对,公钥是 rsa.KEY_TYPE.PKCS8 格式, 私钥是 rsa.KEY_TYPE.PKCS1 格式,我加了 key_type = resty_rsa.KEY_TYPE.PKCS8 可以用了,谢谢帮助
这是generate出来的 -----BEGIN RSA PUBLIC KEY----- MIIBCgKCAQEAtv4b3uiZ95VbrmP1aHBa+dnCi1ji8zckQba5815A42DwKGZiDqwm Q7B9BAXKSWyCOCqRd8f39LYuz4fAPuIXWLwzjXkrdYv2wcvOr+8NpIQ05/Kwy8kt o3Pa3h3Q1Vw7ItWznnz28t6ejPrc0L1l3N/HkMrZnyH23x8FJ8o6k1FhBH28YpuC 9tg4KSbTiOnuHZ/TPnJ2hammRmFEKRpf1PV2lySjVrHXSAQ9+Sr4TwvQJGo9vWCx QjIvgoD06l8NvnLPu4lsYI8BAkMIsd5rzIp6XYyEHV88+wx6e/AmYf1P4Tkd9XZ3 d8NdWkMd8wJgzncrCnYhmBA/6Wm7orINhwIDAQAB -----END RSA PUBLIC KEY-----
这是我的: -----BEGIN RSA PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlKp7UqlyK65w6k3qH99W rp7xtiCNy1uHTX67nVadoOoMCDGXYJpdmQ8bZ3WQRPu0Xw9/s58c/F2BKLD+jAy9 mFZOyxfVCwgKww4mcKWwFApRG3tHwJaDdlm/iXQdpBB/X2mFk3CXmDNK086NXmJX cMqIQKMxmfbEqSSAIdKzLK4gNrakP2i4/tNZt2yDvv458EuY+BfB+qYFl0LjVS9m JoBbXH2dvRtljIrzw0906cPcd+8g/6va0j7beVKIICwrvqop1ziLF51KI5jF/fRf QlgUKMeypwxXhkBcEM6oqPkonutm/8XdPDTXki7+qsCWJNFI2puJkOmYWZ4uGbPQ hQIDAQAB -----END RSA PUBLIC KEY-----
用上面的new出来没问题,也可以正常加解密,用我的错误 new rsa err: wrong tag