开发者

RSA decryption from .NET using PHP

开发者 https://www.devze.com 2023-01-17 12:55 出处:网络
I am not sure where to post this so I am starting here and hoping for the best. I have a public and private key generated for .NET. The keys have (Modulus, Exponent, etc...). I sent the public key to

I am not sure where to post this so I am starting here and hoping for the best. I have a public and private key generated for .NET. The keys have (Modulus, Exponent, etc...). I sent the public key to a third party and they used it to encrypt passwords in a database. I downloaded the encrypted passwords and now I need开发者_StackOverflow to decrypt them on my end. The issue comes in when it has to be decrypted on a unix server. I do not care if I use php, java or any other language as long as it works on the unix box. I am a complete rookie to RSA keys and would appreciate any help or even a direction on where I "should" post this. Thanks in advance....


The values appear to be base64 encoded. You could use phpseclib's pure PHP RSA implementation and do something like this to load the public key:

$rsa->loadKey(array('modulus' => $modulus, 'exponent' => $exponent), CRYPT_RSA_PUBLIC_FORMAT_RAW);

For the private key... maybe you could do something like..

$rsa = new Crypt_RSA();
$rsa->modulus = $modulus;
$rsa->publicExponent = $exponent;
$rsa->exponents = array(1=> $dp, $dq)
$rsa->coefficients = array(2 => $inverseq);
$rsa->primes = array(1 => $p, $q);

Or something like that - I haven't tested the code, but a cursory glance of phpseclib's code suggests that'll work.


There is a nice article about using .NET's key format with PHP: Using PHP to encrypt/decryp/sign/verify data with .NET XML RSA key

0

精彩评论

暂无评论...
验证码 换一张
取 消