Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Write a sample program using Digest::MD5. Looking at the manual, you will realize you basically have three options
  • md5 - produces a (non human readable) binary string 16 bytes long
  • md5hex - 32 bytes of hex
  • md5_base64 - a base 64 string
From 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

In reply to Re: OT: Is MD5 ALWAYS 32 character long? by zakzebrowski
in thread OT: Is MD5 ALWAYS 32 character long? by DaWolf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found