Creating the Hash

← Back

All URLs on Gravatar are based on the use of the hashed value of an email address. Images and profiles are both accessed via the hash of an email, and it is considered the primary way of identifying an identity within the system. To ensure a consistent and accurate hash, the following steps should be taken to create a hash:

  1. Trim leading and trailing whitespace from an email address
  2. Force all characters to lower-case
  3. md5 hash the final string

As an example, let's say we start with " " (note the trailing space which our hypothetical user entered by mistake). If we md5 encode that string directly, we get the following (in PHP):

echo md5( " " );
// "f9879d71855b5ff21e4963273a886bfc"

If we now run that same email address through the above process, you will see that we get a different result (again in PHP):

$email = trim( " " ); // ""
$email = strtolower( $email ); // ""
echo md5( $email );
// "0bc83cb571cd1c50ba6f3e8a78ef1346"

This can easily be combined into a single line:

echo md5( strtolower( trim( " " ) ) );

Once you have generated a consistent hash, you can then request either an image or a profile.

500万彩票 幸运时时彩开奖结果 贵州快3走势 北京pk10 五分时时彩 一分时时彩 凤凰平台app下载 五分时时彩 小米彩票登陆 吉林快3