首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在没有mcrypt的情况下使用ClickBank解密通知数据?

如何在没有mcrypt的情况下使用ClickBank解密通知数据?
EN

Stack Overflow用户
提问于 2018-01-26 21:55:41
回答 1查看 180关注 0票数 1

Mcrypt已经被废弃多年,并最终从php中消失了。不幸的是,我需要从ClickBank解码加密数据,它们的文档只提供mcrypt解决方案。

这是从他们的文件中删掉的。如果没有mcrypt_decode(),我如何做到这一点?

代码语言:javascript
复制
$secretKey = "YOUR SECRET KEY"; // secret key from your ClickBank account

// get JSON from raw body...
$message = json_decode(file_get_contents('php://input'));

// Pull out the encrypted notification and the initialization vector for
// AES/CBC/PKCS5Padding decryption
$encrypted = $message->{'notification'};
$iv        = $message->{'iv'};
error_log("IV: $iv");

// decrypt the body...
$decrypted = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128,
                             substr(sha1($secretKey), 0, 32),
                             base64_decode($encrypted),
                             MCRYPT_MODE_CBC,
                             base64_decode($iv)), "\0..\32");
error_log("Decrypted: $decrypted");

////UTF8 Encoding, remove escape back slashes, and convert the decrypted string to a JSON object...
$sanitizedData = utf8_encode(stripslashes($decrypted));
$order         = json_decode($decrypted);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-26 21:55:41

代码语言:javascript
复制
$notification_array = json_decode(utf8_encode(stripslashes(trim(openssl_decrypt($encrypted,
                                 'AES-256-CBC',
                                 substr(sha1($secretKey), 0, 32),
                                 OPENSSL_ZERO_PADDING, base64_decode($iv)), "\0..\32"))), true);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48470142

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档