Skip to content

Instantly share code, notes, and snippets.

@giulianoriccio
Created March 17, 2020 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save giulianoriccio/da89834cee3633538efba39f11cd82db to your computer and use it in GitHub Desktop.
Save giulianoriccio/da89834cee3633538efba39f11cd82db 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