jdock1 Posted October 21, 2010 Share Posted October 21, 2010 Ok, so there are two functions, one encrypts data, the other one must decrypt. But I do not know how to implement it to decrypt. I need to know how to use the second function (number_decrypt). I need it so I enter the encrypted string into a text field and it outputs the decypted string. I dont need the html, I just dont understand how to implement it. Can someone look at this for me and possibly tell me how I could achieve this? Heres the code: function number_encrypt($plain) { mt_srand ((double) microtime() * 1000000); $password = ''; for ($i=0; $i<10; $i++) { $password .= rand(1,1000); } $salt = substr(md5($password), 0, 2); $password = md5($salt . $plain) . ':' . $salt; return $password; } function number_decrypt($encrypted,$plain) { $stack = explode(':', $encrypted); if (sizeof($stack) != 2) return false; if (md5($stack[1] . $plain) == $stack[0]) { return true; } return false; } Thanks! Link to comment https://forums.phpfreaks.com/topic/216452-i-cant-figure-out-how-to-use-this-one-function/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 21, 2010 Share Posted October 21, 2010 number_decrypt() just tests if the supplied value in $plain is the value that produced the given $encrypted (hashed) value. Sadly, those functions, despite the unfortunate names given them, neither encrypt or decrypt anything because encryption/decryption is a two way process. Those functions are using a md5 hash/checksum and it is a one way process. Once you have the hashed value, the only thing you can do is test if a value that is hashed using the same algorithm matches. Link to comment https://forums.phpfreaks.com/topic/216452-i-cant-figure-out-how-to-use-this-one-function/#findComment-1124758 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.