soadlink Posted December 20, 2006 Share Posted December 20, 2006 I am just curious about the MD5() function. I have converted the complex string [b]÷¨ª®±‰[/b] using the function, and have gotten the result: 4fd39908710727a1038acf8146802710But when I went to test this string on other sites that convert strings to MD5 (using different methods like javascript) they give different outputs. So I am just curious as to what the CORRECT md5 hash for that string is, and if php is even giving the correct hash... or if the other sites are wrong.Here are some of the outputs other sites have given me: 8252934fd1fca2fda8feaa8e20f9b700 (http://www.cs.eku.edu/faculty/styer/460/Encrypt/JS-MD5.html) and e9d9e770c1b72425494f799478ffeba4 (http://b-con.us/pages/md5.php).I also went to a php console to see what was happening, and php gives a 'Notice:' when I hash the string: http://img227.imageshack.us/img227/4882/md5xk0.jpgI just want to be sure the hashes are being calculated correctly. I am working with a little project that adds md5 hashes and/or searches for them in a mysql database, and don't want bad data 8)Thanks! Link to comment https://forums.phpfreaks.com/topic/31330-md5-giving-valid-results-for-complex-strings/ Share on other sites More sharing options...
btherl Posted December 20, 2006 Share Posted December 20, 2006 This is probably to do with character encodings. If you submit data on a website, it goes through several different encodings as it passes through your browser through to the receiving system, and then as it is decoded and passed to md5(). If you want to test different versions of md5(), you either need to take character encoding into account or use characters which are common to most codings, like alphanumeric characters. Link to comment https://forums.phpfreaks.com/topic/31330-md5-giving-valid-results-for-complex-strings/#findComment-144983 Share on other sites More sharing options...
soadlink Posted December 20, 2006 Author Share Posted December 20, 2006 Thanks for the reply! I did change the 'character set' in character map when I chose that string above. It was a mix between unicode and Windows: Western.It appears if I use an all unicode string such as æèçØ×½»ºâ³´¯, all sites give the same output. I guess I could just find a way to just block all md5 conversions that aren't using 'unicode' characters :-\ Link to comment https://forums.phpfreaks.com/topic/31330-md5-giving-valid-results-for-complex-strings/#findComment-144992 Share on other sites More sharing options...
btherl Posted December 20, 2006 Share Posted December 20, 2006 Oh.. about the undefined constant, did you try [code=php:0]md5(string);[/code] or did you try [code=php:0]md5('string');[/code]? Usually that warning is given if you don't quote a string literal. Link to comment https://forums.phpfreaks.com/topic/31330-md5-giving-valid-results-for-complex-strings/#findComment-145000 Share on other sites More sharing options...
soadlink Posted December 20, 2006 Author Share Posted December 20, 2006 [quote author=btherl link=topic=119351.msg488736#msg488736 date=1166604380]Oh.. about the undefined constant, did you try [code=php:0]md5(string);[/code] or did you try [code=php:0]md5('string');[/code]? Usually that warning is given if you don't quote a string literal.[/quote]I used:<?php$str = "÷¨ª®±‰";echo md5($str);?>Edit: Apparently before I didn't use the quotes, so you are correct btherl, now it gives no 'notices', and still the same output. Sorry for that Link to comment https://forums.phpfreaks.com/topic/31330-md5-giving-valid-results-for-complex-strings/#findComment-145010 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.