简体   繁体   English

有没有不变的mycrypt模式吗?

[英]Is there an mycrypt mode that doesnt change?

I am using mcrypt to store credit card numbers in a table. 我正在使用mcrypt将信用卡号存储在表中。 I am also using the same credit card numbers to check if the user has already applied the coupon code. 我还使用相同的信用卡号来检查用户是否已经应用了优惠券代码。

The problem that I am facing is that the mcrypt string always changes, when the user posts their credit card number on the checkout page. 我面临的问题是,当用户在结帐页面上发布其信用卡号时,mcrypt字符串始终会更改。

Is there an mcrypt method that does not change the string each time? 是否有一个mcrypt方法不会每次都更改字符串?

By the way, I am using codeigniter's encryption class to cipher the credit card numbers 顺便说一句,我正在使用codeigniter的加密类对信用卡号进行加密

Any help would be really appricated 任何帮助都会得到真正的应用

Notice: storing and processing credit card data is not recommended providing you know little about security and encryption 注意:不建议您存储和处理信用卡数据,除非您对安全性和加密了解得很少

The function you are using outputs different string but you can check them if the input was indentical. 您正在使用的函数输出不同的字符串,但是您可以检查输入是否相同。

When it comes to functions that return "same strings" everytime, you can use SHA256 hashing function: 对于每次都返回“相同字符串”的函数,可以使用SHA256哈希函数:

<?php
   $string = "123";
   $hash = hash( 'sha256', $string );
   $user_input = "123";

   if(hash( 'sha256', $user_input ) == $hash){
        echo "Correct credit card number";
   } else {
        echo "Did not find a match";
   }
?>

Read more about the hash() method here 在此处阅读有关hash()方法的更多信息

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

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