<?php
include_once "errorCode.php";
class WXBizDataCrypt
{
private $appid;
private $sessionKey;
public function __construct( $appid, $sessionKey)
{
$this->sessionKey = $sessionKey;
$this->appid = $appid;
}
public function decryptData( $encryptedData, $iv, &$data )
{
if (strlen($this->sessionKey) != 24) {
return ErrorCode::$IllegalAesKey;
}
$aesKey=base64_decode($this->sessionKey);
if (strlen($iv) != 24) {
return ErrorCode::$IllegalIv;
}
$aesIV=base64_decode($iv);
$aesCipher=base64_decode($encryptedData);
$result=openssl_decrypt( $aesCipher, "AES-128-CBC", $aesKey, 1, $aesIV);
$dataObj=json_decode( $result );
if( $dataObj == NULL )
{
return ErrorCode::$IllegalBuffer;
}
if( $dataObj->watermark->appid != $this->appid )
{
return ErrorCode::$IllegalBuffer;
}
$data = $result;
return ErrorCode::$OK;
}
}
采用的wx.getGroupEnterInfo获得的密文,采用官方解码方式解不开,解码失败。是否需要在官方提供的解码方式上进行一些改变,或者用其他方
式解码。
使用上方代码即官方解码方式解码
参考下https://developers.weixin.qq.com/community/develop/article/doc/000cccf4a442f8b165a898db456013
运营大佬,希望能注意到我发的帖子~