ideawu / Objective-C-RSA

Doing RSA encryption and decryption with Objective-C on iOS
http://www.ideawu.com/blog/post/132.html
Other
1.15k stars 280 forks source link

解密不出来 #10

Open whihail opened 8 years ago

whihail commented 8 years ago

请问demo中的密钥对从哪里来呀?为什么我用openssl生成的pem格式的密钥对在此解密不出来,在终端中使用openssl能解密出来?

ideawu commented 8 years ago

用 php 生成的:

<?php
$config = array(
        "digest_alg" => "sha512",
        "private_key_bits" => 1024,
        "private_key_type" => OPENSSL_KEYTYPE_RSA,
        );
$res = openssl_pkey_new($config);
$private_key = '';
openssl_pkey_export($res, $private_key);
$details = openssl_pkey_get_details($res);
$public_key = $details["key"];

var_dump($private_key, $public_key);
whihail commented 8 years ago

我的后台语言是java,请问该怎么做?如果也使用pho生成的密钥对有没有问题?

ideawu commented 8 years ago

只要生成的密钥(公/私)字符串和php例子里生成的格式一样即可.

imokoi commented 8 years ago

我使用php生成的密钥也不能解密成功啊,怎么回事

CivelXu commented 8 years ago

字符串过长无法加密