
October 11th, 2012, 08:41 AM
|
|
Registered User
|
|
Join Date: Jul 2012
Posts: 12
Time spent in forums: 3 h 56 m 34 sec
Reputation Power: 0
|
|
|
Using preg_match to check a string is an MD5 hash
Basically I want to check that a string is the result of an MD5 hash.
So the string must be 32 chars long and only contain a-f and 0-9 chars.
I have been doing it like this...
PHP Code:
if (!preg_match('/^[0-9a-f]{32}$/', $string)) {
// false
} else {
// true
}
I was wondering what other ways there are of checking? Have I missed anything, can my code return true for incorrect strings?
Cheers
|