Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: (tye)Re: Compact MD5 representation

by jplindstrom (Monsignor)
on Mar 20, 2001 at 03:30 UTC ( [id://65579]=note: print w/replies, xml ) Need Help??


in reply to (tye)Re: Compact MD5 representation
in thread Compact MD5 representation

The thing is, if I do that it is possible to get an output string with a + / or possibly = in it, and that needs encoding to be kept in a url.

Of course, I could do that myself pretty easily when I have the base64 hash.

Thanks!

/J

Replies are listed 'Best First'.
(tye)Re2: Compact MD5 representation
by tye (Sage) on Mar 20, 2001 at 03:37 UTC

    You could also trivially use tr/// to get a base-64-type encoding that uses only things matching [-\w] which requires no escaping in a URL (to preserve minimal length).

            - tye (but my friends call me "Tye")
Re: Re: (tye)Re: Compact MD5 representation
by chipmunk (Parson) on Mar 20, 2001 at 21:03 UTC
    I had this issue with MD5 hashes recently, but with even more constraints!

    First, on top of using the MD5 hash in a URL, and sending that URL in an email, I also needed to use the MD5 hash in an actual email address. (Thus allowing the recipient to either go to the URL or reply to the email address.) Second, I couldn't translate to a period within the MD5 hash, because that character was already being used for something else.

    I ended up using this translation (the translation from plus to plus is intentional): tr,+=/,+-_, That works fine for the email address. The only iffy part is the plus in the URL; I just made sure that the CGI script doesn't convert the plus to a space.

      OK, I'm (relatively) lazy. Looking at the source code for one Perl MD5 implementation, I see that the base64 output consists of A-Za-z0-9+/. Where does "=" come in? Why do you need to use 65 different characters?

              - tye (but my friends call me "Tye")
        According to the docs for Mime::Base64, '=' is used to pad a Base64 encoded string to a multiple of four bytes.

        For MD5 hashes, they're always a multiple of four bytes anyway, so the '=' isn't needed. This is definitely good to know!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://65579]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-03-28 19:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found