http://qs321.pair.com?node_id=315692


in reply to OT: Is MD5 ALWAYS 32 character long?

Write a sample program using Digest::MD5. Looking at the manual, you will realize you basically have three optionsFrom that, you have to ask yourself, "self, do I want a base 64 string? Self, do I want a human readable 32 byte string? Self, do I want to go for storage and use a binary string?" Personally, because I don't like dealing with binary information, and I don't need a base 64 string, I would use the 32 byte hex string. I would then write a simple test program (below) which shows me the length of a string. (I could enhance it by taking an md5 checksum of the checksum itself, but that's left as an exercise to the user...) Also, I know from database classes that char storage when you have a fix length, is better than varchar storage for fixed length, I would use a char(32) for the column type. (Of course, the database may silently convert char to a varchar2 (like oracle) since the char size is large, but that's an implementation detail of the database system you use.)
Default@z ~ $ more test.pl use Digest::MD5 qw (md5_hex); my $digest = Digest::MD5->new; $digest->add("Hi"); print length($digest->hexdigest);


----
Zak