Ruby equivalent for php openssl_pkey_get_public

L

LiMan

Hello all

I have the php script where the password encoding done using the
openssl:

$key = openssl_get_publickey($certificate);
openssl_public_encrypt($pass,$userPassCrypted,
$key,OPENSSL_PKCS1_PADDING);
openssl_free_key($key);

Now I trying to make the same with ruby

require 'openssl'
cert = OpenSSL::X509::Certificate.new(certificate)
public_key = cert.public_key
passwordSSL = public_key.public_encrypt(password, 1)

The problem here is that these password encoding isn't match

The certificate the same but the publick key
in PHP is:
-----BEGIN PUBLIC KEY-----
....
-----END PUBLIC KEY-----
in ruby is:
-----BEGIN RSA PUBLIC KEY-----
....
-----END RSA PUBLIC KEY-----

I guess here is the difference (keys body also not the same)...

How can I get inside ruby the same public key as in PHP? Or is it
possible convert RSA key by somehow?

Or maybe I have to do it with another way?

Any suggestions highly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top