- $publicKey = new RSA();
- $publicKey->setPublicKey($key);
-
- return $publicKey->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)
- {
- $publicKey = new RSA();
- $publicKey->loadKey($key);
- $publicKey->setPublicKey();
-
- $modulus = $publicKey->modulus->toBytes();
- $exponent = $publicKey->exponent->toBytes();