grenouille Posted October 9, 2006 Share Posted October 9, 2006 hi,i am using an open source (java) filemanager on one of my websites. user data is stored in an xml-file.when a visitor uses the filemanager itself to register, the password is first md5 encrypted and after that base64 encoded (according to the developer).now i want to write my own register-form for this filemanager. so i take the password value, md5() and base64_encode() it, but it gives NOT the saùme result as when the filemanager itself encrypts.f.i password= 19721972 ==> filemanager result = NREVYMjLF45+vX9VM9KAxg==but : $password=19721972, md5($password) ==> 35111560c8cb178e7ebd7f5533d280c6 and then base64_encode($password) ==> MzUxMTE1NjBjOGNiMTc4ZTdlYmQ3ZjU1MzNkMjgwYzY=anyone any idea what may cause this difference? the developer told me he used the Java MessageDigest classto md5 encrypt.If you know the answer, please do not get to technical (if possible) :)thnx in advance. Link to comment https://forums.phpfreaks.com/topic/23418-md5-and-base64-encoding/ Share on other sites More sharing options...
xsist10 Posted October 9, 2006 Share Posted October 9, 2006 I found your problem.You had[code]$password=19721972;md5($password);base64_encode($password);echo $password;[/code]What you want is this[code]$password = 19721972;$password = md5($password);$password = base64_encode($password);echo $password;[/code] Link to comment https://forums.phpfreaks.com/topic/23418-md5-and-base64-encoding/#findComment-106195 Share on other sites More sharing options...
grenouille Posted October 9, 2006 Author Share Posted October 9, 2006 okay, my explanation was a bit confusing but that is exactly what i did. [code]<?$str = 19721972;$str = md5($str);$str = base64_encode($str);echo $str;?>[/code] Link to comment https://forums.phpfreaks.com/topic/23418-md5-and-base64-encoding/#findComment-106199 Share on other sites More sharing options...
xsist10 Posted October 9, 2006 Share Posted October 9, 2006 Sorry... my badYour developer uses raw md5 output...this fixes it[code]$password = 19721972;$password = md5($password, true);$password = base64_encode($password);[/code] Link to comment https://forums.phpfreaks.com/topic/23418-md5-and-base64-encoding/#findComment-106200 Share on other sites More sharing options...
grenouille Posted October 9, 2006 Author Share Posted October 9, 2006 hm, now i get the following error[quote]Warning: Wrong parameter count for md5() in ...[/quote] Link to comment https://forums.phpfreaks.com/topic/23418-md5-and-base64-encoding/#findComment-106203 Share on other sites More sharing options...
xsist10 Posted October 9, 2006 Share Posted October 9, 2006 [url=http://www.php.net/md5]http://www.php.net/md5[/url][code]Note: The optional raw_output parameter was added in PHP 5.0.0 and defaults to FALSE[/code]You must have an older version of PHP running. Link to comment https://forums.phpfreaks.com/topic/23418-md5-and-base64-encoding/#findComment-106205 Share on other sites More sharing options...
grenouille Posted October 9, 2006 Author Share Posted October 9, 2006 php version is 4.2.2could this be the cause of raw output failure? Link to comment https://forums.phpfreaks.com/topic/23418-md5-and-base64-encoding/#findComment-106206 Share on other sites More sharing options...
grenouille Posted October 9, 2006 Author Share Posted October 9, 2006 okay thnx. i'll upgrade first, then i'll annoy you again with my questions :) Link to comment https://forums.phpfreaks.com/topic/23418-md5-and-base64-encoding/#findComment-106208 Share on other sites More sharing options...
xsist10 Posted October 9, 2006 Share Posted October 9, 2006 I found a solution:[code]$password = 19721972;//$password = md5($password, true);$password = pack("H*", md5($password));$password = base64_encode($password);echo $password;[/code] Link to comment https://forums.phpfreaks.com/topic/23418-md5-and-base64-encoding/#findComment-106209 Share on other sites More sharing options...
grenouille Posted October 9, 2006 Author Share Posted October 9, 2006 yep! that's it!thnx a lot.grtz Link to comment https://forums.phpfreaks.com/topic/23418-md5-and-base64-encoding/#findComment-106210 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.