· 7 years ago · Sep 21, 2018, 01:52 PM
1$gz_data = gzcompress($data, 9);
2$data = pack("N", strlen($gz_data)) . $gz_data;
3$secret_key = 'live_sk_a3daex196gc40c4f8oa8a8as9ccx218415aa13fcsdso2ad9h0jaeed6490lld20';
4$bin_key = pack("H*", substr($secret_key, 8));
5$aes_key = substr($bin_key, 0, 16);
6$salt = substr($bin_key, 16, 16);
7$iv = openssl_random_pseudo_bytes(16);
8$encrypted = openssl_encrypt($data, 'aes-128-cbc', $aes_key, true, $iv);
9$digest = hash_hmac('sha256', $data . $iv, $salt, true);
10$data = base64_encode($iv . $digest . $encrypted);