$rsa = new RSA();
$key = [
'modulus' => new BigInteger($result->publickey_mod, 16),
'publicExponent' => new BigInteger($result->publickey_exp, 16)
];
$rsa->loadKey($key, RSA::PUBLIC_FORMAT_RAW);
$rsa->setPublicKey($key);
$rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
$password = base64_encode($rsa->encrypt($password));