Jump to content

Archived

This topic is now archived and is closed to further replies.

PigsHidePies

Simple md5() question

Recommended Posts

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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.