#1
  1. A Change of Season
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,558
    Rep Power
    222

    Is the string md5?


    Is this reliable?

    PHP Code:
    function isValidMd5($md5 ='')
    {
        return 
    preg_match('/^[a-f0-9]{32}$/'$md5);
    }

    echo 
    isValidMd5('5d41402abc4b2a76b9719d911017c592'); 
  2. #2
  3. Headless Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,966
    Rep Power
    9647
    That regex will match the MD5 hashes you're expecting, though I would allow uppercase letters too. There is no way of knowing whether such a string is an MD5 hash.
  4. #3
  5. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,971
    Rep Power
    4576
    What's the scenario where you'd need to validate a hash?
    -- Cigars, whiskey and wild, wild women. --

IMN logo majestic logo threadwatch logo seochat tools logo