Des3Utils.php 640 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace addons\YunfastPay\common\utils;
  3. /**
  4. * 解密
  5. * @package addons\YunfastPay\common\utils
  6. */
  7. class Des3Utils
  8. {
  9. /**
  10. * 加密
  11. *
  12. * @param string $input
  13. * @param string $key
  14. * @return string
  15. */
  16. public static function encrypt($input, $key)
  17. {
  18. return openssl_encrypt($input, 'des-ede3', $key, 0);
  19. }
  20. /**
  21. * 解密
  22. *
  23. * @param string $input
  24. * @param string $key
  25. * @return string
  26. */
  27. public static function decrypt($encrypted, $key)
  28. {
  29. return openssl_decrypt(base64_decode($encrypted), 'des-ede3', $key, OPENSSL_RAW_DATA);
  30. }
  31. }