Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Perl

Idiom #307 XOR encrypt/decrypt string

Create a function that XOR encrypts/decrypts a string

sub xor_crypt {
    my ($b, $k) = @_;
    return $b ^ $k;
}

Perl's bitwise operator ^ will xor strings.
sysutils
encrypted := xorstring(key, original);

New implementation...
< >
anonymous