Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Extremely simple cryptor
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