Jump to content

md5 hashes are they only alphanumeric?


monkeytooth

Recommended Posts

I have a user input string via GET variable that I want to always make sure falls within the constraints of type of variable its set for, which is a md5 hash.

So I want to put together using preg_match or something using a regex construct (even though I suck with regex) to verify that all the characters in the string are valid characters for a md5 hash, where if its not then I want to kick back an error. The idea of making something like that isnt the issue for me so much as not knowing whether or not an md5 has is strictly alphanumeric or if it can possibly even if one in a million chance have something else from an underscore to a exclamation point or other characters. Ive tried to find out searching google and other sites for an answer but my search terms I guess are way to open to find something distinctly close to what I am looking for answer wise, so I figured I'd give you guys a shot see if anyone knows.

Link to comment
Share on other sites

well they are chars, and we know the charset now.

 

preg_match('#^[a-z0-9]{32}$#i', $_GET['something']);

 

somethign like what should work I think.

 

Actually, since the letters only go to F, you don't need to look all the way to z...

preg_match('#^[a-f0-9]{32}$#i', $_GET['something']);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.