PHP RSA front and back end encrypted communication

Party B generates a pair of keys (public key and private key), and discloses the public key to Party A. After Party A obtains the public key, it encrypts the data to be transmitted with the public key and sends it to Party B. Party B obtains the public key. After encrypting the data, decrypt it with the private key