PHP rsa get public key from pem file

后端 未结 3 697
清歌不尽
清歌不尽 2021-01-15 05:05

How can i get publickey from pem file which is created based on rsa 364. installed crypt(RSA.php) library still getting below error

Fatal error: Call to unde

3条回答
  •  自闭症患者
    2021-01-15 05:19

    this is how to load public key in a php and how to know the number of bits used in its encryption and how to encrypt data. remember to split the data into chunks with maximum size of key bytes size.

    ";
    
    $res=openssl_get_publickey($pubKey);   //convert pubkey into resource
    $array=openssl_pkey_get_details($res); //read the resource details
    $chunksize= $array['bits'];            //this is the chunk size 4096
    
    
    $data = 'plaintext data goes here, please encrypt and decrypt the following data';
    openssl_public_encrypt($data, $encrypted, $pubKey);
    ?>
    

提交回复
热议问题