Used to decrypt your profile files (users/<username>/*.txt).
First, you need to know the encryption key table
It is as follows (0 based):
x1F, x07, x09, x01, x0B, x02, x05, x05
x03, x11, x28, x0C, x23, x16, x1B, x02
Algorithm for DE-cryption is as follows: (Reverse to encrypt, but there are some odd things that have to be done before encryption works.)
Code: Select all
cut out 'redshirt2' header
key index = 0
for each line in crypted file:
next line if line is blank
for each character in line
if( character is < 0x20) write char to output file, next character
//YES, increment is done BEFORE accessing the table, so the x1F is skipped first time
key index = key index + 1
key index = key index MODULUS 16
character = character - encryption key at key index
if character < 0x20 add 0x5f to character
write decrypted character to output file
next character
write newline to output file
next line in file
Perl script:
( Reads from STDIN and prints to STDOUT
Usage: perl decode.pl < encrypted_file > decrypted_file )
decode.pl:
Code: Select all
#!/usr/bin/perl
@table =(
0x1F, 0x07, 0x09, 0x01, 0x0B, 0x02, 0x05, 0x05,
0x03, 0x11, 0x28, 0x0C, 0x23, 0x16, 0x1B, 0x02 );
my $first_line = 1;
while(<>)
{
next if /^$/;
chomp;
if( $first_line ) {
s/^redshirt2//;
$first_line=0;
}
my @chars = split(//);
foreach $char (@chars)
{
if( ord($char) > 0x20 )
{
++$key_index;
$char = chr(ord($char)-$table[$key_index%16]);
if( ord($char) < 0x20 )
{ $char = chr( ord($char) + 0x5f ); }
}
}
print @chars, "\n";
}




