S
Starfry Starfry
Hi,
I'm writing a little code to do some RSA stuff and I need to extract the
public exponent and modulus for passing to a browser that will use them
in Javascript.
I've done considerable digging but have drawn a blank as I can't find
any complete documentation of the full RSA class definition.
What I am trying right now is to do:
key = RSA.new(1024)
private_key = key.to_pem
public_modulus = key.public_key.n
public_exponent = key.public_key.e
This generates a new key and assigns the private key to a variable. I'd
like to get the public exponent and modulus returned as a hex encoded
string, similar to the output of "openssl rsa -noout -modulus"
However, I can't find suitable documentation so I don't know what method
(if any) I can use. I'd hoped for "key.public_key.n.to_h" but that does
not seem to work.
So, If anyone can give advice I'd appreciate it!
Also, A general question: how do I look up class definitions of
"standard" classes that are not documented in RDoc? Is there something
similar to a C header file? (sorry, I'm quite new to Ruby).
Many thanks for your help.
I'm writing a little code to do some RSA stuff and I need to extract the
public exponent and modulus for passing to a browser that will use them
in Javascript.
I've done considerable digging but have drawn a blank as I can't find
any complete documentation of the full RSA class definition.
What I am trying right now is to do:
key = RSA.new(1024)
private_key = key.to_pem
public_modulus = key.public_key.n
public_exponent = key.public_key.e
This generates a new key and assigns the private key to a variable. I'd
like to get the public exponent and modulus returned as a hex encoded
string, similar to the output of "openssl rsa -noout -modulus"
However, I can't find suitable documentation so I don't know what method
(if any) I can use. I'd hoped for "key.public_key.n.to_h" but that does
not seem to work.
So, If anyone can give advice I'd appreciate it!
Also, A general question: how do I look up class definitions of
"standard" classes that are not documented in RDoc? Is there something
similar to a C header file? (sorry, I'm quite new to Ruby).
Many thanks for your help.