如何存储信用卡账号

<?php
$crypt = new crypt();
$crypt->cleartext = '1234567890123456';
$crypt->generate_iv();
$crypt->encrypt();
$ciphertext = $crypt->ciphertext;
$iv = $crypt->iv;
$string = base64_encode($iv . $ciphertext);
?>
Store this string in the database. Upon retrieval, reverse this process as follows:
<?php
$string = base64_decode($string);
$iv_size = mcrypt_get_iv_size($algorithm, $mode);
$ciphertext = substr($string, $iv_size);
$iv = substr($string, 0, $iv_size);
$crypt = new crypt();
$crypt->iv = $iv;
$crypt->ciphertext = $ciphertext;
$crypt->decrypt();
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks .
$cleartext = $crypt->cleartext;
?>
 
This implementation assumes a consistent algorithm and mode. If these are not hardcoded, you must
also store them because you need them in order to decrypt the data. The key is the only data that must
be kept secret.
posted @ 2014-04-04 17:22  wint  Views(122)  Comments(0)    收藏  举报