Decryption errorline 2225

Get help with using the PHP Secure Communications Library.

Moderator: Nuxius

Forum rules
The purpose of this forum is to provide support for phpseclib, a pure PHP SSH / SFTP / RSA library.

Posts by new users are held in a moderation queue and are not publicly visible until the post is approved.

Decryption errorline 2225

Postby kajonglin » Mon Oct 21, 2013 5:43 am

Hi,

I am a nooby on RSA php and I need your help, please,

I encrypt as below :
$private_key=file_get_contents('/export/home/.ssh/private_key');
$rsa = new Crypt_RSA();
$rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
$rsa->setPrivateKeyFormat(CRYPT_RSA_PRIVATE_FORMAT_PKCS1);
$rsa->setPublicKeyFormat(CRYPT_RSA_PUBLIC_FORMAT_PKCS1);
$rsa->loadKey($private_key);
$ciphertext=base64_encode($rsa->encrypt($plaintext));

and redirect data on the other page to decrypt as below :
$public_key=file_get_contents('/export/home/.ssh/public_key');
$rsa = new Crypt_RSA();
$rsa->setPublicKeyFormat(CRYPT_RSA_PUBLIC_FORMAT_PKCS1);
$rsa->loadKey($public_key);
$rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
$plaintext=$rsa->decrypt(base64_decode($ciphertext));

but plaintext in decryption alway null, and show Decryption error "/../../.." line 2225

How can I fix this ?
kajonglin
Traveler
 
Posts: 2
Joined: Mon Oct 21, 2013 4:24 am

Re: Decryption errorline 2225

Postby TerraFrost » Wed Oct 23, 2013 5:06 am

Can you generate a private / public key that you'd be willing to share and if you're able to reproduce the problem with that key pair could you post it along with the plaintext and ciphertext (base64-encoded)?

Thanks!
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: Decryption errorline 2225

Postby kajonglin » Thu Oct 24, 2013 3:08 am

I found I have a mistake on encode & decode so Thank you very much. :)
kajonglin
Traveler
 
Posts: 2
Joined: Mon Oct 21, 2013 4:24 am


Return to phpseclib support

Who is online

Users browsing this forum: No registered users and 2 guests