Created
February 15, 2019 08:15
-
-
Save Achterstraat/ab25a03c84b4716b5edd724e57f027f4 to your computer and use it in GitHub Desktop.
Extremely simple cryptor
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
function secret($string, $action = 'encrypt', $secret = 'random', $host = 'achterstraat.com', $method = 'AES-256-CBC') | |
{ | |
switch($action) | |
{ | |
case 'decrypt': { | |
return openssl_decrypt(base64_decode($string), $method, hash('sha256', $secret), 0, mb_substr(hash('sha256', $host), 0, 16)); | |
} | |
default: { | |
return base64_encode(openssl_encrypt($string, $method, hash('sha256', $secret), 0, mb_substr(hash('sha256', $host), 0, 16))); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment