Skip to main content

02.小程序的EAS解密

1支付宝小程序手机号解密

加密数据
{
"response": "EaieI1W9gPK0zClNbA7P0T6svaSYq/1xejihTXNVSH0WyCjBIcP2xOwaAevaYgb4aeQ5NNRQaqbZgVvfJKfaLQ==",
"sign": "iSHQH/r3rZiBx7N49SwQNHx2Y0B6OP2ePvhS+T2XKw9+dzt3T1W9T0cHSldFlkczcdPQ05Pi/bEygsZxip6StCNEqse7ou/nXx9QOAVNoBgZfb4bmFJxOl8DYeuF8VKQy+NdxuvRGJFpmVynZtSNy31BfD4663IowMj80/pfnmLJCEKqoS2oHWtGRRM7oIFEdCH5IJKCsq79qxFEPwmQVid2uN0XuL/Rg+lKN9eAbTGcBttVZGaI11vGDEBUq9sNksVJXWUHofszCeD9jGz8pGoNvApRt8Swe2RnVtWcnQ+Zh+G105fPpp3RYNZBSBV9EJJ5la5IEv8KfAwjW7jGFg=="
}
解密函数
/**
* 解密
*
* return mix
*/
function decryptData(string $encrypted_data)
{
$key = env('EAS');
$aesKey=base64_decode($key);
$iv = 0;
$aesIV=base64_decode($iv);
$aesCipher=base64_decode($encrypted_data);
$result=openssl_decrypt( $aesCipher, "AES-128-CBC", $aesKey, 1, $aesIV);
return $result;
}

解密过程
echo decryptData('EaieI1W9gPK0zClNbA7P0T6svaSYq/1xejihTXNVSH0WyCjBIcP2xOwaAevaYgb4aeQ5NNRQaqbZgVvfJKfaLQ==');

// {"code":"10000","msg":"Success","mobile":"1342XXXXXXX"}

摘自