Data-ChipsChallenge
view release on metacpan or search on metacpan
## compress\_map (grid MAP\_DATA)
Given the 2D grid `MAP_DATA`, the map is compressed and returned in raw binary.
## decode\_password (bin RAW\_BINARY)
Given the encoded level password in raw binary (4 bytes followed by a null byte),
this function returns the 4 ASCII byte password in clear text. This is the password
you'd type into Chip's Challenge.
Passwords are decoded by XORing the values in the raw binary by hex `0x99`,
if you're curious.
## encode\_password (string PASSWORD)
Given the plain text password `PASSWORD`, it encodes it and returns it as
a 5 byte binary string (including the trailing null byte).
## random\_password
Returns a random 4-letter password.
lib/Data/ChipsChallenge.pm view on Meta::CPAN
my $bin = join("",@compressed);
return $bin;
}
=head2 decode_password (bin RAW_BINARY)
Given the encoded level password in raw binary (4 bytes followed by a null byte),
this function returns the 4 ASCII byte password in clear text. This is the password
you'd type into Chip's Challenge.
Passwords are decoded by XORing the values in the raw binary by hex C<0x99>,
if you're curious.
=cut
sub decode_password {
my ($self,$data) = @_;
my @chars = split(//, $data, 5);
# Decode each character.
( run in 1.016 second using v1.01-cache-2.11-cpan-26ccb49234f )