Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP7 Decoder for ionCube Encoder)
- *
- * @ Version : 4.0.9.0
- * @ Author : DeZender
- * @ Release on : 08.08.2019
- * @ Official site : http://DeZender.Net
- *
- */
- namespace App\Http\Controllers;
- class AESController
- {
- /**
- * @param $data
- * @param $passphrase
- * @param null $salt ONLY FOR TESTING
- * @return string encrypted data in base64 OpenSSL format
- */
- static public function encrypt($data, $passphrase, $salt = NULL)
- {
- $salt = $salt ?: openssl_random_pseudo_bytes(8);
- list($key, $iv) = self::evpkdf($passphrase, $salt);
- $ct = openssl_encrypt($data, 'aes-256-cbc', $key, true, $iv);
- return self::encode($ct, $salt);
- }
- /**
- * @param string $base64 encrypted data in base64 OpenSSL format
- * @param string $passphrase
- * @return string
- */
- static public function decrypt($base64, $passphrase)
- {
- list($ct, $salt) = self::decode($base64);
- list($key, $iv) = self::evpkdf($passphrase, $salt);
- $data = openssl_decrypt($ct, 'aes-256-cbc', $key, true, $iv);
- return $data;
- }
- static public function evpkdf($passphrase, $salt)
- {
- $dx = '';
- for ($salted = ''; strlen($salted) < 48; $salted .= $dx) {
- $dx = md5($dx . $passphrase . $salt, true);
- }
- $key = substr($salted, 0, 32);
- ...................................................................
- .......................................
- .............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement