Javier Suazo Javier Suazo - 1 year ago 113
Ruby Question

Yodlee API PKI, trying to encrypt data rsa/ecb/pkcs1padding using rails/ruby

I'm creating an app using yodlee api, so far everything good, but right now, I'm having this block related to the PKI feature of yodlee. I'm not able to encrypt the data using "RSA/ECB/PKCS1Padding" as they request, all I found so far are java examples, anyone with a snippet of code, or a reference to make this possible on ruby?

Answer Source

I guess you are referring to this manual to integrate Yodlee API with PKI feature.

Have a look into the ruby's OpenSSL classes. Encryption using RSA is possible with the OpenSSL::PKey::RSA class, see also this intro doc. Basically you have to load the public key returned from the API, and use the public_encrypt method to encrypt the data and hex-encode it in the end. The encryption uses the PKCS1_PADDING by default which is just what you want.

A complete example is available in this SO answer.