【问题标题】:How can I decrypt ClickBank notification data using PHP without mcrypt?如何在没有 mcrypt 的情况下使用 PHP 解密 ClickBank 通知数据?
【发布时间】:2018-07-06 07:28:52
【问题描述】:

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

这是从他们的文档中删除的。没有 mcrypt_decode() 怎么办?

$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);

【问题讨论】:

    标签: php mcrypt php-openssl clickbank


    【解决方案1】:
    $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);
    

    【讨论】:

    • 啊,我们走了。 “ClickBank 使用 CBC-AES-256”。很好的提及。
    猜你喜欢
    • 1970-01-01
    • 2011-06-13
    • 2020-12-25
    • 2019-04-13
    • 2021-10-05
    • 1970-01-01
    • 1970-01-01
    • 2019-11-16
    • 1970-01-01
    相关资源
    最近更新 更多