xor syntax

I

IanW

If I have a string $encrypted that has been "XORed with 0xAA" and I want to
decode that into $decrypted, how do I do this in Perl?

Thanks
Ian
 
A

Anno Siegel

IanW said:
If I have a string $encrypted that has been "XORed with 0xAA" and I want to
decode that into $decrypted, how do I do this in Perl?

Not much of an encryption... Like in any language, you xor it with
0xAA again to decrypt. Untested:

my $plain = $cipher ^ chr( 0xaa) x length $str;

Anno
 
A

A. Sinan Unur

If I have a string $encrypted that has been "XORed with 0xAA" and I
want to decode that into $decrypted, how do I do this in Perl?

The binary XOR operator in Perl is ^

D:\Home\asu1\UseNet\clpmisc> perl -e "print 0x7 ^ 0x4, qq{\n}"
3

See also perldoc perlop.

Sinan
 
D

Dr.Ruud

IanW schreef:
If I have a string $encrypted that has been "XORed with 0xAA" and I
want to decode that into $decrypted, how do I do this in Perl?

Encrypt it again.
:)
 
I

IanW

Anno Siegel said:
Not much of an encryption... Like in any language, you xor it with
0xAA again to decrypt. Untested:

my $plain = $cipher ^ chr( 0xaa) x length $str;

thanks, that's spot-on.. well, except that $cipher and $str should be the
same.

Ian
 
A

Anno Siegel

IanW said:
thanks, that's spot-on.. well, except that $cipher and $str should be the
same.

Right.

my $plain = $cipher ^ chr( 0xaa) x length $cipher;

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top