public function encrypt($input)
{
// Create a random IV. Not using mcrypt to generate one, as to not have a dependency on it.
$iv = substr(uniqid("", true), 0, Cipher::IV_SIZE);
// Encrypt the data
$encrypted = openssl_encrypt($input, "AES-256-CBC", $this->secretKey, 0, $iv);
// Encode the data with IV as prefix
return base64_encode($iv . $encrypted);
}
/** * Helper method to encrypt data using clientSecret as key * * @param $data * @return string */ public function encrypt($data) { return $this->cipher->encrypt($data); }