#!/usr/bin/perl -w
# Created by Ben Okopnik on Sat Sep  8 10:11:23 UTC 2001

$pass = shift or die "Usage: ", $0 =~ /([^\/]*$)/, " passwd < file\n";

undef $/;			# Set "slurp mode"
@file = split //, <>;		# Make a 'character' array from file

# Tweak the password itself to avoid "known text XOR" attack
@pass = map{
	$x = ord;
	$y = ( $x + 10 ) ** 2 % 256;
	$z = ( $x - 10 ) ** 2 % 256;
	chr ( $y ^ $z )
	} split //, $pass;

# Do The Right Thang!
print chr( ord $file[$_] ^ ord $pass[$_ % scalar @pass] ) for 0 .. $#file
