Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require '../vendor/autoload.php';
- use phpseclib3\File\X509;
- use phpseclib3\Crypt\PublicKeyLoader;
- use phpseclib3\Crypt\RSA;
- $texto_para_criptografar = "teste";
- $x509 = new X509();
- $cert = $x509->loadX509(file_get_contents('./teste.crt'));
- $rsa = PublicKeyLoader::load($x509->getPublicKey());
- $rsa = $rsa->withPadding(RSA::ENCRYPTION_PKCS1);
- $cipher_text = base64_encode($rsa->encrypt($texto_para_criptografar));
Add Comment
Please, Sign In to add comment