Class: MTProto::Crypto::RSAKey
- Inherits:
-
Object
- Object
- MTProto::Crypto::RSAKey
- Defined in:
- lib/mtproto/crypto/rsa_key.rb
Instance Attribute Summary collapse
-
#fingerprint ⇒ Object
readonly
Returns the value of attribute fingerprint.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(pem_string) ⇒ RSAKey
constructor
A new instance of RSAKey.
Constructor Details
#initialize(pem_string) ⇒ RSAKey
Returns a new instance of RSAKey.
11 12 13 14 15 16 |
# File 'lib/mtproto/crypto/rsa_key.rb', line 11 def initialize(pem_string) raise ArgumentError, "pem_string is required" if pem_string.nil? || pem_string.empty? @key = OpenSSL::PKey::RSA.new(pem_string) @fingerprint = calculate_fingerprint end |
Instance Attribute Details
#fingerprint ⇒ Object (readonly)
Returns the value of attribute fingerprint.
9 10 11 |
# File 'lib/mtproto/crypto/rsa_key.rb', line 9 def fingerprint @fingerprint end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
9 10 11 |
# File 'lib/mtproto/crypto/rsa_key.rb', line 9 def key @key end |
Class Method Details
.find_by_fingerprint(fingerprints, public_key) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/mtproto/crypto/rsa_key.rb', line 22 def self.find_by_fingerprint(fingerprints, public_key) raise ArgumentError, "public_key is required" if public_key.nil? || public_key.empty? key = new(public_key) key if fingerprints.include?(key.fingerprint) end |
.from_pem(pem_string) ⇒ Object
18 19 20 |
# File 'lib/mtproto/crypto/rsa_key.rb', line 18 def self.from_pem(pem_string) new(pem_string) end |