shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

encryption.php (849B)


      1 <?php
      2 /**
      3  * @package		OpenCart
      4  * @author		Daniel Kerr
      5  * @copyright	Copyright (c) 2005 - 2017, OpenCart, Ltd. (https://www.opencart.com/)
      6  * @license		https://opensource.org/licenses/GPL-3.0
      7  * @link		https://www.opencart.com
      8 */
      9 
     10 /**
     11 * Encryption class
     12 */
     13 final class Encryption {
     14 	/**
     15      * 
     16      *
     17      * @param	string	$key
     18 	 * @param	string	$value
     19 	 * 
     20 	 * @return	string
     21      */	
     22 	public function encrypt($key, $value) {
     23 		return strtr(base64_encode(openssl_encrypt($value, 'aes-128-cbc', hash('sha256', $key, true))), '+/=', '-_,');
     24 	}
     25 	
     26 	/**
     27      * 
     28      *
     29      * @param	string	$key
     30 	 * @param	string	$value
     31 	 * 
     32 	 * @return	string
     33      */
     34 	public function decrypt($key, $value) {
     35 		return trim(openssl_decrypt(base64_decode(strtr($value, '-_,', '+/=')), 'aes-128-cbc', hash('sha256', $key, true)));
     36 	}
     37 }