Help with encryption

So I have this key information that I got by generating a private and
public key in VB, but it gave it to me in the form of a modulus and
exponent in an XML file. Now, I need to encrypt some stuff in ruby using
that info. On this site:
http://blog.internautdesign.com/2007/11/2/ruby-openssl-rsa-public-key-from-modulus-and-exponent/comments/165,
they explain how to do that, but clearly this info is in integer format
so I need to convert my stuff, which looks similar to:
tzG8K55r0VFT0uwhQa+PEoavFOH7TF9X5TWfyYc1a6JfY91KWpaj0 into a smiliar
format. Right now I am decoding it from Base64 which I assumes leave me
with a Hex value, but I am unsure about how to proceed. Anyone have any
ideas? Thanks,

-S

Shandy N. wrote:

So I have this key information that I got by generating a private and
public key in VB, but it gave it to me in the form of a modulus and
exponent in an XML file. Now, I need to encrypt some stuff in ruby using
that info. On this site:
http://blog.internautdesign.com/2007/11/2/ruby-openssl-rsa-public-key-from-modulus-and-exponent/comments/165,
they explain how to do that, but clearly this info is in integer format
so I need to convert my stuff, which looks similar to:
tzG8K55r0VFT0uwhQa+PEoavFOH7TF9X5TWfyYc1a6JfY91KWpaj0 into a smiliar
format. Right now I am decoding it from Base64 which I assumes leave me
with a Hex value, but I am unsure about how to proceed. Anyone have any
ideas? Thanks,

If you are doing asymmetric encryption in Rails, I recommend the Sentry
gem. It makes encrypting model attributes trivially easy. It also
includes some documentation for how to work with keys, though I don’t
recall anything on modulus/exponent format. Most encryption I’ve seen
uses OpenSSL to generate a public/private key pair. If you aren’t
required to use your VB-generated pair, you might want to think about
going the standard way and generating a new pair using OpenSSL.


Josh S.
http://blog.hasmanythrough.com

Josh S. wrote:

If you are doing asymmetric encryption in Rails, I recommend the Sentry
gem. It makes encrypting model attributes trivially easy. It also
includes some documentation for how to work with keys, though I don’t
recall anything on modulus/exponent format. Most encryption I’ve seen
uses OpenSSL to generate a public/private key pair. If you aren’t
required to use your VB-generated pair, you might want to think about
going the standard way and generating a new pair using OpenSSL.


Josh S.
http://blog.hasmanythrough.com

It’s really not an issue using the VB or Ruby generated keys, because I
can get both to generate keys, the problem is that I need to be able to
port the keys to be used by the other. For exmaple, if I generate my key
in Ruby I need to get it into a format that VB can use it, but it seems
that between the two languages it is apples and oranges. Right now I can
get VB to generate an xml file holding the “parts” that make up a key,
the problem happens when I try and get those parts into the correct
format so ruby can use the key.

So if I have this:

private_key = OpenSSL::PKey::RSA.new(1024)

I can set the modulus and exponent for the keys like this:

private_key.n = …
private_key.e = …

The problms is that the keys from VB is just a lot of characters, for
example:

PEoavFOH7TF9X5TWfyYc1aJfY91Wpaj0osU2t3gQk9cSpDWDhNHXjXa7oSAWScQNMmR8

and I need to make it look like this:

42112068797415937200008076003921911646192548127635288

Thanks,

-S

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs