Skip to content

Instantly share code, notes, and snippets.

@ezegg
Last active October 26, 2021 21:01
Show Gist options
  • Save ezegg/8d54c98b8fbdce263409eabaf8afabe6 to your computer and use it in GitHub Desktop.
Save ezegg/8d54c98b8fbdce263409eabaf8afabe6 to your computer and use it in GitHub Desktop.
<?php
class AesCipher
{
const CIPHER = 'AES-256-CBC';
const SECRET_KEY = 'SOMETHINGKEY';
const SECRET_IV = 'SOMETHINGIV';
public static function encrypt($text)
{
$output = false;
$output = openssl_encrypt($text, self::CIPHER, base64_decode(self::SECRET_KEY), OPENSSL_RAW_DATA, base64_decode(self::SECRET_IV));
return base64_encode($output);
}
public static function decrypt($cypherText)
{
$output = false;
$output = openssl_decrypt(base64_decode($cypherText), self::CIPHER, base64_decode(self::SECRET_KEY), OPENSSL_RAW_DATA, base64_decode(self::SECRET_IV));
return $output;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment