ok, so i have some links that will be generated for some ads on my website via php. Now the problem i have is simply i understand how md5 works and it’s not an encryption and it can not be re-rendered in its rarest form….. i have some mysql ids that i want to use as the data to select witch ad to query the database for , but i do not want my users to have access to the ads id….. so i was hoping someone could show me how to use the hash/salt method in this case…..
Please note: i have been looking through this site for this answer and i see people time and time again say salt/hash is not encryption i understand that but its not as simple to attempt to hack my site if the links were hashed as they would be if they were just simple integers.
php script:
<?
function SuperAd($id){
$sql = mysql_query("SELECT * FROM `ads` WHERE `id`= $id");
while($ad = mysql_fetch_array($sql)){
$title = $ad['title'];
// here is where i want to encrypt
$adlink = $ad['id'];
}
}
?>
Adding salt is just a securer addition to hashing. And hashing is one way only. It sounds like you want some way of encrypting your
$ad['id'], so that instead of users seeing:/viewad/1/they see:
/viewad/12lk3jx09c8faf/right?
Just Google for some quick encryption / decryption algorithms.
EDIT: Here is a quick S.O. question that may help you:
Best way to use PHP to encrypt and decrypt passwords?