Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

converting tiny binary strings for internet transmission

by zentara (Archbishop)
on Mar 28, 2002 at 20:20 UTC ( [id://155096]=perlquestion: print w/replies, xml ) Need Help??

zentara has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have a password that is encrypted with RC4, which results in a short binary string of non-prinable characters. I am looking for something like uuencode to change it to printable characters, so it can be stored as a cookie, retreived, and decoded. The problem is that the string is very short, and uuencode is probably overkill on it. What are good methods to do this conversion?
  • Comment on converting tiny binary strings for internet transmission

Replies are listed 'Best First'.
Re: converting tiny binary strings for internet transmission
by Anonymous Monk on Mar 29, 2002 at 07:54 UTC
    my $printable = unpack "H*", $string;
    Or to UUencode as you mentioned in your question:
    my $printable = unpack "u*", $string;
Re: converting tiny binary strings for internet transmission
by Juerd (Abbot) on Mar 28, 2002 at 21:17 UTC
    Try any serializer. FreezeThaw, Storable. UUEncoding it is not such a bad idea
      Thanks for that pointer to serializers. I have done the following as a first attempt. Just send the hex. The one thing that gets me with this, is that when the last print occurs, it messes up my display, putting everything in binary. How do I prevent this? Anyone?
      #!/usr/bin/perl use strict; use warnings; open(FH,"<adminpass"); binmode FH; my $binstring= <FH>; print "$binstring\n"; my $hexstr= unpack "H*",$binstring; print "$hexstr\n"; my $binback= pack "H*",$hexstr; print "$binback\n";

Log In?
Username:
Password:

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

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

      No recent polls found