Last active
October 26, 2021 21:01
-
-
Save ezegg/8d54c98b8fbdce263409eabaf8afabe6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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