gpt4 book ai didi

PHP MySQL : decrypt a column value from a MySQL row that was encrypted upon insertion and parse to JSON

转载 作者:行者123 更新时间:2023-11-30 22:40:19 24 4
gpt4 key购买 nike

一切正常,我只想使用以下示例从数据库中解密包含信用卡号的 db 列:

$decp = $crypt->decrypt($encp);

有问题的行是:

'Number' => $row['cardNumber'],

整个代码是:

// get the cards
$jsonresult = $conn->query("SELECT nameOnCard, cardNumber, cardType, cardDate, ccvCode
FROM cy_user_credit_cards
WHERE accountNumber='$accountNumber'");
$creditCard = [];
while ($row = mysqli_fetch_assoc($jsonresult)) {
array_push($creditCard, [
'Name' => $row['nameOnCard'],
'Number' => $row['cardNumber'],
'Type' => $row['cardType'],
'Date' => $row['cardDate'],
'ccv' => $row['ccvCode']
]);
}

// Convert the Array to a JSON String and echo it
$ccJSON = json_encode($creditCard);
echo $ccJSON;
$conn->close();

最佳答案

我想你会想做这样的事情:

// get the cards
$jsonresult = $conn->query("SELECT nameOnCard, cardNumber, cardType, cardDate, ccvCode
FROM cy_user_credit_cards
WHERE accountNumber='$accountNumber'");
$creditCard = [];
while ($row = mysqli_fetch_assoc($jsonresult)) {
array_push($creditCard, [
'Name' => $row['nameOnCard'],
'Number' => $crypt->decrypt($row['cardNumber']),
'Type' => $row['cardType'],
'Date' => $row['cardDate'],
'ccv' => $row['ccvCode']
]);
}

// Convert the Array to a JSON String and echo it
$ccJSON = json_encode($creditCard);
echo $ccJSON;
$conn->close();

请记住,如果不是绝对必要,您真的不想将所有这些信用卡详细信息存储在您的数据库中。我建议您到其他地方处理信用卡付款。

关于PHP MySQL : decrypt a column value from a MySQL row that was encrypted upon insertion and parse to JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31305781/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com