Class: ExtensisPortfolio::RSAEncryption
- Inherits:
-
Object
- Object
- ExtensisPortfolio::RSAEncryption
- Defined in:
- lib/extensis_portfolio/rsa_encryption.rb
Instance Method Summary collapse
- #encrypt(string) ⇒ Object
-
#initialize(modulus, exponent) ⇒ RSAEncryption
constructor
A new instance of RSAEncryption.
Constructor Details
#initialize(modulus, exponent) ⇒ RSAEncryption
Returns a new instance of RSAEncryption.
3 4 5 6 |
# File 'lib/extensis_portfolio/rsa_encryption.rb', line 3 def initialize(modulus, exponent) seq = OpenSSL::ASN1::Sequence.new([OpenSSL::ASN1::Integer.new(modulus), OpenSSL::ASN1::Integer.new(exponent)]) @public_key = OpenSSL::PKey::RSA.new(seq.to_der) end |
Instance Method Details
#encrypt(string) ⇒ Object
8 9 10 |
# File 'lib/extensis_portfolio/rsa_encryption.rb', line 8 def encrypt(string) Base64.encode64(@public_key.public_encrypt(string)) end |