Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Untainting cookies

by merlyn (Sage)
on Apr 11, 2001 at 06:08 UTC ( [id://71578]=note: print w/replies, xml ) Need Help??


in reply to Untainting cookies

Are you so concerned about the size that you can't use hex instead of base64? Hex works fine, and has very safe characters which can be interpolated everywhere.

Here's what Apache::Session used the last time I looked:

require MD5; my $session = MD5->hexhash(MD5->hexhash(time.{}.rand().$$));

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: Untainting cookies
by MeowChow (Vicar) on Apr 11, 2001 at 20:18 UTC
    How about just tr'ing the initial Base64 ID like so:
    $id =~ tr|+/=|___|; # or $id =~ tr|+/=|000|;
    You would lose just a few bits of randomness (acceptable in this application), but would be left with a shorter ID that's an easy match with a /\w/.
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-25 16:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found