#!/usr/bin/env perl use strict; my ($target_file, $key_file) = @ARGV; my ($t, $k); open(F, $target_file) and $t = join('', <F>) and close(F); open(F, $key_file) and $k = join('', <F>) and close(F); for (my ($i, $j) = (0, 0); $i < length($t); $i++, $j++) { $j = 0 if ($j >= length($k)); substr($t, $i, 1, pack("C", unpack("C", substr($t, $i, 1)) ^ unpack("C", substr($k, $j, 1)))); } $t =~ s/([^\.\*\-_a-zA-Z0-9])/sprintf("%%%02lX",unpack("C",$1))/eg; print $t;
#!/usr/bin/env perl use strict; my ($target_file, $key_file) = @ARGV; my ($t, $k); open(F, $target_file) and $t = join('', <F>) and close(F); open(F, $key_file) and $k = join('', <F>) and close(F); $t =~ s/%([A-F0-9][A-F0-9])/pack("C", hex($1))/gie; for (my ($i, $j) = (0, 0); $i < length($t); $i++, $j++) { $j = 0 if ($j >= length($k)); substr($t, $i, 1, pack("C", unpack("C", substr($t, $i, 1)) ^ unpack("C", substr($k, $j, 1)))); } print $t;