Skip to content

Instantly share code, notes, and snippets.

@vbcupu
Last active November 24, 2021 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vbcupu/ff483dc6a95671524719012c8ed7add6 to your computer and use it in GitHub Desktop.
Save vbcupu/ff483dc6a95671524719012c8ed7add6 to your computer and use it in GitHub Desktop.
<?php
require_once 'vendor/autoload.php';
/* function decrypt dan kompresi dijadikan satu */
function stringDecrypt($key, $string)
{
$encrypt_method = 'AES-256-CBC';
// hash
$key_hash = hex2bin(hash('sha256', $key));
// iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning
$iv = substr(hex2bin(hash('sha256', $key)), 0, 16);
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key_hash, OPENSSL_RAW_DATA, $iv);
return \LZCompressor\LZString::decompressFromEncodedURIComponent($output);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment