# Creating an RSA public key from a modulus and exponent

**URL:** <https://rubytalk.org/t/creating-an-rsa-public-key-from-a-modulus-and-exponent/41862>\
**Category:** ruby-talk\
**Created:** [2 November 2007 01:21 UTC](https://rubytalk.org/t/creating-an-rsa-public-key-from-a-modulus-and-exponent/41862 "2007-11-02T01:21:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rodney\_Carvalho](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Rodney\_Carvalho](https://rubytalk.org/u/Rodney_Carvalho)\
**Post date:** [2 November 2007 01:21 UTC](https://rubytalk.org/t/creating-an-rsa-public-key-from-a-modulus-and-exponent/41862/1 "2007-11-02T01:21:21Z")

</div>

I know how to create a new keypair using:

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

But, I'm looking for how to create a public key when I have the modulus  
and exponent value of that key. Any help would be appreciated.

Thanks,

rodney

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Rodney\_Carvalho](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Rodney\_Carvalho](https://rubytalk.org/u/Rodney_Carvalho)\
**Post date:** [2 November 2007 19:01 UTC](https://rubytalk.org/t/creating-an-rsa-public-key-from-a-modulus-and-exponent/41862/2 "2007-11-02T19:01:06Z")

</div>

Rodney Carvalho wrote:

> I know how to create a new keypair using:
> 
> OpenSSL::PKey::RSA.new(1024)
> 
> But, I'm looking for how to create a public key when I have the modulus  
> and exponent value of that key. Any help would be appreciated.
> 
> Thanks,
> 
> rodney

OK, after many hours of playing I've answered my own question and posted  
it on my blog. Here you go:

[http://blog.internautdesign.com/2007/11/2/ruby-openssl-rsa-public-key-from-modulus-and-exponent](http://blog.internautdesign.com/2007/11/2/ruby-openssl-rsa-public-key-from-modulus-and-exponent)

-Rodney Carvalho  
[www.internautdesign.com](http://www.internautdesign.com)

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Shandy\_Nantz](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@Shandy\_Nantz](https://rubytalk.org/u/Shandy_Nantz)\
**Post date:** [11 December 2007 21:23 UTC](https://rubytalk.org/t/creating-an-rsa-public-key-from-a-modulus-and-exponent/41862/3 "2007-12-11T21:23:13Z")

</div>

Rodney Carvalho wrote:

> OK, after many hours of playing I've answered my own question and posted  
> it on my blog. Here you go:
> 
> [http://blog.internautdesign.com/2007/11/2/ruby-openssl-rsa-public-key-from-modulus-and-exponent](http://blog.internautdesign.com/2007/11/2/ruby-openssl-rsa-public-key-from-modulus-and-exponent)
> 
> -Rodney Carvalho  
> [www.internautdesign.com](http://www.internautdesign.com)

How did you get them into that format though? I have been trying the  
smae thing for the better part of a week and can't get them into the  
correct format.

-S

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Rodney\_Carvalho](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Rodney\_Carvalho](https://rubytalk.org/u/Rodney_Carvalho)\
**Post date:** [11 December 2007 23:52 UTC](https://rubytalk.org/t/creating-an-rsa-public-key-from-a-modulus-and-exponent/41862/4 "2007-12-11T23:52:33Z")

</div>

response posted on blog.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
