Skip to content

Instantly share code, notes, and snippets.

@ajepe
Created October 29, 2018 11:07
Show Gist options
  • Save ajepe/bb824f52817d6c9958d0ece0097c727b to your computer and use it in GitHub Desktop.
Save ajepe/bb824f52817d6c9958d0ece0097c727b to your computer and use it in GitHub Desktop.
3desencyption
<?php
/**
* Created by PhpStorm.
* User: Raihan
* Date: 10-Jul-17
* Time: 4:37 AM
*/
class CryptOpenssl{
private $hash;
function __construct($hash){
$key = md5($hash,TRUE);
$key .= substr($key,0,8);
$this->hash = $key;
}
/**
* @param $data
* @return string
*/
public function Encrypt($data){
$encData = openssl_encrypt($data, 'DES-EDE3', $this->hash, OPENSSL_RAW_DATA);
$encData = base64_encode($encData);
return $encData;
}
/**
* @param $data
* @return string
*/
public function Decrypt($data){
$data = base64_decode($data);
$decData = openssl_decrypt($data, 'DES-EDE3', $this->hash, OPENSSL_RAW_DATA);
return $decData;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment