IcbcEncrypt.php 674 B

123456789101112131415161718192021
  1. <?php
  2. include_once 'AES.php';
  3. include_once 'IcbcConstants.php';
  4. class IcbcEncrypt{
  5. public static function encryptContent($content, $encryptType, $encryptKey, $charset){
  6. if(IcbcConstants::$ENCRYPT_TYPE_AES == $encryptType){
  7. return AES::AesEncrypt($content,base64_decode($encryptKey));
  8. }else{
  9. throw new Exception("Only support AES encrypt!");
  10. }
  11. }
  12. public static function decryptContent($encryptedContent, $encryptType, $encryptKey, $charset){
  13. if(IcbcConstants::$ENCRYPT_TYPE_AES == $encryptType){
  14. return AES::AesDecrypt($encryptedContent,base64_decode($encryptKey));
  15. }else{
  16. throw new Exception("Only support AES decrypt!");
  17. }
  18. }
  19. }
  20. ?>