Class: Xml::Kit::Crypto::RsaCipher
- Inherits:
-
Object
- Object
- Xml::Kit::Crypto::RsaCipher
- Defined in:
- lib/xml/kit/crypto/rsa_cipher.rb
Constant Summary collapse
- ALGORITHM =
"#{::Xml::Kit::Namespaces::XMLENC}rsa-1_5"
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
readonly
Returns the value of attribute algorithm.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
Instance Method Summary collapse
- #decrypt(cipher_text) ⇒ Object
- #encrypt(plain_text) ⇒ Object
-
#initialize(algorithm, key) ⇒ RsaCipher
constructor
A new instance of RsaCipher.
Constructor Details
#initialize(algorithm, key) ⇒ RsaCipher
Returns a new instance of RsaCipher.
10 11 12 13 |
# File 'lib/xml/kit/crypto/rsa_cipher.rb', line 10 def initialize(algorithm, key) @algorithm = algorithm @key = key end |
Instance Attribute Details
#algorithm ⇒ Object (readonly)
Returns the value of attribute algorithm.
8 9 10 |
# File 'lib/xml/kit/crypto/rsa_cipher.rb', line 8 def algorithm @algorithm end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
8 9 10 |
# File 'lib/xml/kit/crypto/rsa_cipher.rb', line 8 def key @key end |
Class Method Details
.matches?(algorithm) ⇒ Boolean
15 16 17 |
# File 'lib/xml/kit/crypto/rsa_cipher.rb', line 15 def self.matches?(algorithm) ALGORITHM == algorithm end |
Instance Method Details
#decrypt(cipher_text) ⇒ Object
23 24 25 |
# File 'lib/xml/kit/crypto/rsa_cipher.rb', line 23 def decrypt(cipher_text) @key.private_decrypt(cipher_text) end |
#encrypt(plain_text) ⇒ Object
19 20 21 |
# File 'lib/xml/kit/crypto/rsa_cipher.rb', line 19 def encrypt(plain_text) @key.public_encrypt(plain_text) end |