Skip to content
instance method

OpenSSL::PKey::RSA#public_encrypt

(::String data, ?::Integer padding) -> ::String
rsa.public_encrypt(string) → String
rsa.public_encrypt(string, padding) → String

Encrypt string with the public key. padding defaults to PKCS1_PADDING, which is known to be insecure but is kept for backwards compatibility. The encrypted string output can be decrypted using private_decrypt.

Deprecated in version 3.0. Consider using PKey::PKey#encrypt and PKey::PKey#decrypt instead.