PigsHidePies Posted September 23, 2006 Share Posted September 23, 2006 Hello, I was wondering if there was a way to limit the output of md5()..say for instance I don't want 32 characters and instead only want 8...how would I limit how many chars md5 outputs? Thanks Link to comment https://forums.phpfreaks.com/topic/21778-simple-md5-question/ Share on other sites More sharing options...
Daniel0 Posted September 23, 2006 Share Posted September 23, 2006 You could do this: [code]substr(md5("something"),0,8);[/code] but then you would risk hash collisions.MD5 hashes are [i]always[/i] 32 characters long, while SHA1 is [i]always[/i] 41 (or is it 42?) characters long? Link to comment https://forums.phpfreaks.com/topic/21778-simple-md5-question/#findComment-97260 Share on other sites More sharing options...
PigsHidePies Posted September 23, 2006 Author Share Posted September 23, 2006 Thanks daniel0...sha1() hashes are actually 40 characters long. I am not going to be using this short hash for a password, rather just a random 8 char string for a simple task. Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/21778-simple-md5-question/#findComment-97261 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.