- $rsa = new RSA();
- $rsa->setPublicKey($key);
-
- return $rsa->getPublicKey(RSA::PUBLIC_FORMAT_PKCS8);
- }
-
- /**
- * Extracts the modulo and exponent reference from a public PEM key
- *
- * @param string $key public PEM key
- * @param string $modulus (ref) modulo reference
- * @param string $exponent (ref) exponent reference
- *
- * @return void
- */
- public static function pemToMe(string $key, &$modulus, &$exponent)
- {
- $rsa = new RSA();
- $rsa->loadKey($key);
- $rsa->setPublicKey();
-
- $modulus = $rsa->modulus->toBytes();
- $exponent = $rsa->exponent->toBytes();