Created
December 10, 2018 21:25
-
-
Save ahgood/d708e3763bdd4323a45e7cc454e6b7c9 to your computer and use it in GitHub Desktop.
Common PHP encrypt decrypt
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
// encrypt | |
function encrypt(string $data, string $key, string $method) { | |
$encrypted = openssl_encrypt($data, $method, $key, OPENSSL_RAW_DATA); | |
$encrypted = base64_encode($encrypted); | |
return $encrypted; | |
} | |
// decrypt | |
function decrypt(string $data, string $key, string $method) { | |
$data = base64_decode($data); | |
$data = openssl_decrypt($data, $method, $key, OPENSSL_RAW_DATA); | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment