Skip to content

Instantly share code, notes, and snippets.

@IP-CAM
Forked from giulianoriccio/encryption.php
Created April 3, 2020 22:52
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 IP-CAM/10e8ce676b3d99d1224e968c8af85ddc to your computer and use it in GitHub Desktop.
Save IP-CAM/10e8ce676b3d99d1224e968c8af85ddc to your computer and use it in GitHub Desktop.
opencart 1.5.6.4 PHP 7.2+
<?php
final class Encryption {
private $key;
public function __construct($key) {
$this->key = hash('sha256', $key, true);
}
public function encrypt($value) {
return strtr(base64_encode(openssl_encrypt($value, 'aes-128-cbc', $this->key)), '+/=', '-_,');
}
public function decrypt($value) {
return trim(openssl_decrypt(base64_decode(strtr($value, '-_,', '+/=')), 'aes-128-cbc', $this->key));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment