PHP crypt () - returned md5 hash

The docs ( http://php.net/manual/de/function.crypt.php ) for the crypt () function show the following example for an MD5 hash:

$1$rasmusle$rISCgZzpwk3UhDidwXvin0

      

I understand that "$ 1 $" is a prefix that contains information that the hash is an MD5 hash.

But how does the rest of the string contain the MD5 hash? Usually it should be a 32 char (0-9, af) string, right?

I'm sure this is a stupid question, but I still want to ask.

+3


source to share


1 answer


Usually it should be a 32 char (0-9, af) string, right?

This is not true (at least strictly speaking). Technically, an MD5 hash is a 128-bit numeric value . The form you're used to is just the hexadecimal representation of that number. It is often chosen because they are easily exchanged as strings (128-bit integers are difficult to handle. After all, a typical integer variable usually only contains 64 bits). Consider the following examples:



  • md5("test")

    in hexadecimal representation (base 16):098f6bcd4621d373cade4e832627b4f6

  • md5("test")

    in base 64 view :CY9rzUYh03PK3k6DJie09g==

  • md5("test")

    in decimal (base 10) representation:12707736894140473154801792860916528374

  • md5("test")

    in base 27 view (never used, just because I can and prove my point):ko21h9o9h8bc1hgmao4e69bn6f

All of these lines represent the same numerical value only in different bases.

+3


source







All Articles