FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


checking md5 hash





imagefree
Is the regex below a valid one to check md5


Code:
[0-9a-fA-F]{32}
[/i]
coreymanshack
imagefree wrote:
Is the regex below a valid one to check md5


Code:
[0-9a-fA-F]{32}
[/i]


no clue what you mean. could you explain clearer.
AftershockVibe
He's on about regular expressions. I thought you'd have been all over them!

See here:
http://uk3.php.net/eregi
or more generally:
http://en.wikipedia.org/wiki/Regular_expression

What imagefree posted (for whatever reason) was the "pattern" parameter.
Cool
Hogwarts
AftershockVibe wrote:
http://uk3.php.net/eregi

Ewwwwwwwwwwwwwww. Why would you suggest eregi? Shocked

preg_match, thanks. It can do case insensitive, too Mad



It looks fine; however you'd best do with preg_match('/0-9a-f/i', $string);

(Having an i after your delimiters (/ in this case) causes it to be case-insensitive.)
imagefree
coreymanshack wrote:
imagefree wrote:
Is the regex below a valid one to check md5


Code:
[0-9a-fA-F]{32}
[/i]


no clue what you mean. could you explain clearer.


in other words, i meant what are the possible characters in md5 hash?
AftershockVibe
Hogwarts wrote:

Ewwwwwwwwwwwwwww. Why would you suggest eregi? Shocked

preg_match, thanks. It can do case insensitive, too Mad

It looks fine; however you'd best do with strtolower(preg_match('/0-9a-f/i', $string);

(Having an i after your delimiters (/ in this case) causes it to be case-insensitive.)


What particularly makes eregi() unacceptable? It does its job. It doesn't even do it badly!
Confused
Hogwarts
http://www.ozzu.com/programming-forum/php-preg-match-and-ereg-t93568.html

Faster, more semantically correct REGEX, isn't defunct

phpknowhow wrote:
Preg functions are faster and better for complex patterns. Its also Perl compatible, if you are familiar with that language. I have made it a habit to always use preg functions. The syntax is not very hard to learn when compared to ereg, so I don't find any reason why to use ereg, unless your just starting out with regular expressions. Even so, its probably better to just forget learning ereg in the first place.

Preg also has the function preg_match_all() which is extremely useful, and has no counterpart in the ereg function group.


Source: http://www.webmaster-talk.com/php-forum/115768-preg-vs-ereg.html

Basically, you'll be hard-pressed to find any advantages to using ereg. It's simply a baaaaad function Sad
AftershockVibe
That's pretty much all I found with a quick google... seems a little vague. I wouldn't say that eregi() was bad though for something this trival or it's somehow surprising that it was suggested.

Horses for courses. Wink
coreymanshack
Why would you want to check if it were a possible MD5 hash.

EDIT: i wasn't sure what he ment by "check md5" i understand now.
Hogwarts
coreymanshack wrote:
Why would you want to check if it were a possible MD5 hash.

EDIT: i wasn't sure what he ment by "check md5" i understand now.


Obviously, he's trying to validate input data or search for something somewhere in a document -_-
imagefree
please answer my question
kacsababa
imagefree wrote:
in other words, i meant what are the possible characters in md5 hash?

I don't know why you ask the user for an md5 hash, but never mind.
An md5 hash is a 32 digit hexidecimal number, that means it can contain 0-9, A-F, so you thought right. Smile
Hogwarts
imagefree wrote:
please answer my question


I'm going to go out on a limb here and make myself look like a tosser, but actually read the damned thread already Sad

Hogwarts wrote:
It looks fine; however you'd best do with preg_match('/0-9a-f/i', $string);

(Having an i after your delimiters (/ in this case) causes it to be case-insensitive.)
imagefree
Hogwarts wrote:
imagefree wrote:
please answer my question


I'm going to go out on a limb here and make myself look like a tosser, but actually read the damned thread already Sad

Hogwarts wrote:
It looks fine; however you'd best do with preg_match('/0-9a-f/i', $string);

(Having an i after your delimiters (/ in this case) causes it to be case-insensitive.)


i am actually asking this question because i read somewhere else too that possible characters in md5 are 0-9, a-z, and A-Z, but my personal tests on millions of md5 hashes show that it contains just 0-9 and a-z (no capitals). I just wanted to ensure the same, or a suggestion.

reply.
rvec
in an md5 hash a is the same as A. And if you make your thing case-insensitive it'll also take both (which you already did and the pattern Hogwarts made also does). So it doesn't make a difference.
coreymanshack
this whole topic seems just a little .. awkward.
Hogwarts
wikipedia wrote:
An MD5 hash is typically expressed as a 32 digit hexadecimal number


Hexadecimal is 0-9a-f, case insensitive
Agent ME
Hogwarts wrote:
wikipedia wrote:
An MD5 hash is typically expressed as a 32 digit hexadecimal number


Hexadecimal is 0-9a-z, case insensitive

Hexadecimal uses a-f, not a-z. (Hexa decimal = 6 + 10 = 16. 0-9a-f is 16 characters.)
Hogwarts
Eep >.>

My bad.

Refer to previous sentence,

Hogwarts wrote:
It looks fine; however you'd best do with preg_match('/0-9a-f/i', $string);


Of course, if I didn't need to keep repeating myself, no mistake would have been made to begin with -.-
Related topics
PHPBB Eklentileri
Auto-Patcher Xp (Aug) Released
Intelligence test
[man] phpBB 2.0.19 (Style Changer/Demo Mod) SQL Injection
Does anyone know the Linksys Passphrase to WEP Key Algorithm
MD5...
md5 encryption not reliable.
Decryption of text excrypted using md5() and crypt() tags
PHP Hashing and Salting
Cookies
md5() Password Protection
Login System Tutorial Part 1 Creating Registration
hashing your passwords
MD5 Hash
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.