I'm trying with PHP to use the ENCODE and DECODE functions of MySQL to encode a credit card number and then decode it. I used terminal to encode a cc number and can successfully echo the encoded data but not the decoded, original cc number. Here's the code:
<?php
@ $db = mysql_pconnect('localhost', 'webauth', 'webauth');
if (!$db)
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
mysql_select_db('auth');
$result = mysql_query("select * from auth where name like 'kenuser'");
if (!$result)
{
echo 'Error - no result for query.';
exit;
}
$encodedCC = mysql_result($result,0,'pass');
$result2 = mysql_query("select DECODE($encodedCC,'thepass')");
$decodedCC = $result2;
echo '<p>Encoded CC: '.$encodedCC.'</p>';
//This works.
echo '<p>Decoded CC: '.$decodedCC.'</p>';
//This does not show decoded cc number.
?>