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

I need to encrypt three strings, each stored as MySql varchar's, email_address, first_name, last_name.

So I need to convert "larry@perl.com" , "Larry" and "Monk" into encrypted strings.

I thought I'd use crypt::cbc to encrypt "larry@perl.com" but that gives me a string with some characters that I figure could cause me problems, so I then converted the result into a hex string with the following:
(my $str = shift) =~ s/(.|\n)/sprintf("%02lx", ord $1)/eg;

Problem is that's not very efficient, my output is twice as long as my input.

What's a good way to convert "larry@perl.com" into "aBcDeFgH123456" for example, so both strings are the same or similar length, if indeed that's possible.

HeebyGeeby

Replies are listed 'Best First'.
Re: Encrypting Strings
by Gangabass (Vicar) on Sep 18, 2009 at 11:45 UTC
Re: Encrypting Strings
by Anonymous Monk on Sep 18, 2009 at 11:39 UTC
    Problem is that's not very efficient, my output is twice as long as my input.

    Its twice as efficient, try ->encrypt_hex