Advertisement
Guest User

Untitled

a guest
Mar 10th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.0.9.0
  8. * @ Author : DeZender
  9. * @ Release on : 08.08.2019
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. namespace App\Http\Controllers;
  15.  
  16. class AESController
  17. {
  18. /**
  19. * @param $data
  20. * @param $passphrase
  21. * @param null $salt ONLY FOR TESTING
  22. * @return string encrypted data in base64 OpenSSL format
  23. */
  24. static public function encrypt($data, $passphrase, $salt = NULL)
  25. {
  26. $salt = $salt ?: openssl_random_pseudo_bytes(8);
  27. list($key, $iv) = self::evpkdf($passphrase, $salt);
  28. $ct = openssl_encrypt($data, 'aes-256-cbc', $key, true, $iv);
  29. return self::encode($ct, $salt);
  30. }
  31.  
  32. /**
  33. * @param string $base64 encrypted data in base64 OpenSSL format
  34. * @param string $passphrase
  35. * @return string
  36. */
  37. static public function decrypt($base64, $passphrase)
  38. {
  39. list($ct, $salt) = self::decode($base64);
  40. list($key, $iv) = self::evpkdf($passphrase, $salt);
  41. $data = openssl_decrypt($ct, 'aes-256-cbc', $key, true, $iv);
  42. return $data;
  43. }
  44.  
  45. static public function evpkdf($passphrase, $salt)
  46. {
  47. $dx = '';
  48.  
  49. for ($salted = ''; strlen($salted) < 48; $salted .= $dx) {
  50. $dx = md5($dx . $passphrase . $salt, true);
  51. }
  52.  
  53. $key = substr($salted, 0, 32);
  54. ...................................................................
  55. .......................................
  56. .............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement