正在显示
1 个修改的文件
包含
6 行增加
和
16 行删除
| 1 | <?php | 1 | <?php |
| 2 | - | ||
| 3 | namespace lib; | 2 | namespace lib; |
| 4 | 3 | ||
| 4 | +use wx\ErrorCode; | ||
| 5 | class WXBizDataCrypt | 5 | class WXBizDataCrypt |
| 6 | { | 6 | { |
| 7 | private $appid; | 7 | private $appid; |
| @@ -29,15 +29,11 @@ class WXBizDataCrypt | @@ -29,15 +29,11 @@ class WXBizDataCrypt | ||
| 29 | */ | 29 | */ |
| 30 | public function decryptData( $encryptedData, $iv, &$data ) | 30 | public function decryptData( $encryptedData, $iv, &$data ) |
| 31 | { | 31 | { |
| 32 | - if (strlen($this->sessionKey) != 24) { | ||
| 33 | - return ErrorCode::$IllegalAesKey; | ||
| 34 | - } | 32 | + |
| 35 | $aesKey=base64_decode($this->sessionKey); | 33 | $aesKey=base64_decode($this->sessionKey); |
| 36 | 34 | ||
| 37 | 35 | ||
| 38 | - if (strlen($iv) != 24) { | ||
| 39 | - return ErrorCode::$IllegalIv; | ||
| 40 | - } | 36 | + |
| 41 | $aesIV=base64_decode($iv); | 37 | $aesIV=base64_decode($iv); |
| 42 | 38 | ||
| 43 | $aesCipher=base64_decode($encryptedData); | 39 | $aesCipher=base64_decode($encryptedData); |
| @@ -45,16 +41,10 @@ class WXBizDataCrypt | @@ -45,16 +41,10 @@ class WXBizDataCrypt | ||
| 45 | $result=openssl_decrypt( $aesCipher, "AES-128-CBC", $aesKey, 1, $aesIV); | 41 | $result=openssl_decrypt( $aesCipher, "AES-128-CBC", $aesKey, 1, $aesIV); |
| 46 | 42 | ||
| 47 | $dataObj=json_decode( $result ); | 43 | $dataObj=json_decode( $result ); |
| 48 | - if( $dataObj == NULL ) | ||
| 49 | - { | ||
| 50 | - return ErrorCode::$IllegalBuffer; | ||
| 51 | - } | ||
| 52 | - if( $dataObj->watermark->appid != $this->appid ) | ||
| 53 | - { | ||
| 54 | - return ErrorCode::$IllegalBuffer; | ||
| 55 | - } | 44 | + |
| 45 | + | ||
| 56 | $data = $result; | 46 | $data = $result; |
| 57 | - return ErrorCode::$OK; | 47 | + |
| 58 | } | 48 | } |
| 59 | 49 | ||
| 60 | } | 50 | } |
-
请 注册 或 登录 后发表评论