On 6/20/07, oryann9 <[EMAIL PROTECTED]> wrote: snip
> > my $plaintext = do { local $/ = undef; <> }; > > my $pad = "X" x length $plaintext; > > > > my $encryptedtext = $plaintext ^ $pad;
snip
I like it to, but dont understand how it is encrypting. Will you kindly expalin?
$plaintext is the contents of the file(s) passed in on the commandline (or stdin if none are passed in). $pad is the character X repeated until there are as many Xs as characters in $plaintext $encryptedtext is the result of xor'ing $plaintext with pad. xor has the following truth table A B R 0 0 0 0 1 1 1 0 1 1 1 0 so if I have 01101100 and I xor it with 01110001 I get 00011101. This is the "encrypted value". If I xor the result 00011101 with the key 01110001 I get the original value back. 01101100 plaintext 01110001 key 00011101 "encrypted" 00011101 "encrypted" 01110001 key 01101100 plaintext -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/