Class: Minke::Encryption::Encryption
- Inherits:
-
Object
- Object
- Minke::Encryption::Encryption
- Defined in:
- lib/minke/encryption/encryption.rb
Instance Method Summary collapse
- #decrypt_string(string) ⇒ Object
- #encrypt_string(string) ⇒ Object
- #fingerprint ⇒ Object
-
#initialize(private_key_file) ⇒ Encryption
constructor
A new instance of Encryption.
Constructor Details
#initialize(private_key_file) ⇒ Encryption
Returns a new instance of Encryption.
4 5 6 7 |
# File 'lib/minke/encryption/encryption.rb', line 4 def initialize(private_key_file) @key_file = private_key_file @key = OpenSSL::PKey::RSA.new File.read private_key_file end |
Instance Method Details
#decrypt_string(string) ⇒ Object
13 14 15 |
# File 'lib/minke/encryption/encryption.rb', line 13 def decrypt_string(string) @key.private_decrypt(Base64.decode64(string)) end |
#encrypt_string(string) ⇒ Object
9 10 11 |
# File 'lib/minke/encryption/encryption.rb', line 9 def encrypt_string(string) Base64.encode64(@key.public_encrypt(string)) end |
#fingerprint ⇒ Object
17 18 19 |
# File 'lib/minke/encryption/encryption.rb', line 17 def fingerprint SSHKey.new(File.read(@key_file)).md5_fingerprint end |