Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 11
    if your string is based on only a random integer, why not just use the random integer? they haystack doesnt get any deeper by hashing it... and by cutting the hash of you actually deminish the little entropy you had to start with. Commented Sep 13, 2014 at 14:23
  • 4
    Keep in mind md5 will result in a 30 character limit and always lowercase characters. Commented Nov 3, 2014 at 15:12
  • 4
    Additionally, rand() shouldn't be used for cryptography. If you're looking to generate a crypographically sound string, use openssl_random_pseudo_bytes. Commented Feb 23, 2015 at 4:44
  • md5(rand()) only offers 2^32 possible values. This means after, on average, 2^16 random strings you will expect one to repeat. Commented Jun 29, 2015 at 3:45
  • 3
    Well..i would bet the OP is not talking about "securely random strings". This solution is compact, easy and pretty to remember, for the right use cases. And, if you need to take care of possible collisions, why not to prepend/append a timestamp to the random string? :) Commented Dec 29, 2016 at 14:10