(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version



Adding Gravatars with Perl


2009/01/12

This morning I added Gravatars to the comments here. If you don't have a Gravatar, you can go create one at the Gravatar site.

Adding Gravatars to a site is fairly simple to do - it's just a matter of doing an MD5 hash on the email supplied in the comment form. The Gravatar site has sample code and plugins etc. exist for common platforms.



Your email is never displayed but it might someday be possible to reverse engineer it from the hash (see Wikipedia MD5). If that concerns you, either do not use Gravatars or use an email that doesn't matter for this (see examples in the comments).

The Gravatar site has more explanation in its FAQ

MD5 is plenty good for obfuscating the email address of users across the wire. if you're thinking of rainbow tables, those are all geared at passwords (which are generally shorter, and less globally different from one another) and not email addresses, furthermore they are geared at generating anything that matches the hash, NOT the original data being hashed. If you are thinking about being able to reproduce a collision, you still dont necessarily get the actual email address being hashed from the data generated to create the collision. In either case the work required to both construct and operate such a monstrocity would be prohibitively costly. If we left your password laying around in the open as a plain md5 hash someone might be able to find some data (not necessarily your password) which they could use to log in as you... Leaving your email address out as an md5 hash, however, is not going to cause a violent upsurge in the number of fake rolex watch emails that you get. Lets face it there are far more lucrative, easier, ways of getting email address. I hope this helps ease your mind.

Simple command line code to do this is:

#!/usr/bin/perl
use Digest::MD5  qw(md5_hex);
$data=<>;
chomp $data;
$digest = md5_hex($data);
print " $data = http://www.gravatar.com/avatar.php?gravatar_id=$digest\n";
 

Obviously squeezing that into my comments code took a little more work, but I think it is all set now. Older comments won't show gravatars - only comments you add now that include an email address.




Click here to add your comments





Mon Jan 12 15:48:25 2009: Subject:   TonyLawrence

gravatar
This is an example using my normal email address.





Mon Jan 12 15:49:10 2009: Subject:   TonyLawrence

gravatar
This comment uses a different email address.





Mon Jan 12 15:49:40 2009: Subject:   TonyLawrence

gravatar
And this left the email blank

Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



numly esn 59798-090112-515114-30
numly barcode

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.

book graphic Internet Income guide

My Hard Truths about Easy Money on the Internet will show you how to make money on the Internet!

 I sell and support
 Kerio Mail server




pavatar.jpg
More:
       - Perl
       - Blogging


Unix/Linux Consultants

Skills Tests

Guest Post Here











My Favorites

Change Congress