If you have a 4096 bit key pair and are trying to use a public key that begins with:
-----BEGIN RSA PUBLIC KEY-----
and you need to convert it for this function to use, you can convert it by prepending the static header information:
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
Such as:
$start_key = str_replace('-----BEGIN RSA PUBLIC KEY-----', '', $start_key);
$start_key = trim(str_replace('-----END RSA PUBLIC KEY-----', '', $start_key));
$key = 'MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A' . str_replace("\n", '', $start_key);
$key = "-----BEGIN PUBLIC KEY-----\n" . wordwrap($key, 64, "\n", true) . "\n-----END PUBLIC KEY-----";