package TOCUNRST;
require Exporter;
@ISA = qw/Exporter/;
@EXPORT = qw/toc_unroast/;


##This code is hereby placed in the public domain.  David Garfield.  April 3, 2001
sub toc_unroast {
my @roast;

@roast = (unpack 'c*', 'Tic/Toc') x 20;

push @_, '0x2408105c23001130', 'password', '0x152b206b1129241c20296418222d1b39327d073b36023e3b760e' unless @_;

for my $pw (@_) {
    my $inpw;
    
    $inpw = $pw;

    ## This next line is the real unroaster:
    $pw = pack 'c*', map { 0xff & (hex(substr($pw, 2+2*$_, 2)) ^ $roast[$_]) } ( 0 .. (length($pw)/2-2) ) if $pw =~ m/^0x(?:[0-9a-fA-F][0-9a-fA-F])+$/;

    # printf "%s = %s\n", $inpw, $pw;
	return $pw;
}
}

1;