Method: RTunnel::Crypto.encrypt_with_key
- Defined in:
- lib/rtunnel/crypto.rb
.encrypt_with_key(key, data) ⇒ Object
Encrypts some data with a public key. The matching private key will be required to decrypt the data.
34 35 36 37 38 39 40 41 42 |
# File 'lib/rtunnel/crypto.rb', line 34 def self.encrypt_with_key(key, data) if key.kind_of? OpenSSL::PKey::RSA key.public_encrypt data, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING elsif key.kind_of? OpenSSL::PKey::DSA key.public_encrypt encrypted_data else raise 'Unsupported key type' end end |