The OpenSSL function for encryption and decryption can be used to encrypt and decrypt a string in PHP.