简体   繁体   English

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

[英]How can I decrypt ClickBank notification data using PHP without mcrypt?

Mcrypt has been deprecated for years and is finally gone from php. Mcrypt已被弃用多年,终于从php中消失了。 Unfortunately I need to decode encrypted data from ClickBank and their documentation only offers mcrypt solutions. 不幸的是,我需要对ClickBank中的加密数据进行解码,并且它们的文档仅提供mcrypt解决方案。

This is cut from their documentation. 这是从他们的文档中删除的。 How can I do this without mcrypt_decode()? 没有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);
$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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM