sub getXPkey { my $key = shift; my @encoded = ( unpack 'C*', $Registry->{$key} )[ reverse 52 .. 66 ]; # Get indices my @indices; foreach ( 0 .. 24 ) { my $index = 0; # Shift off remainder ( $index, $_ ) = quotient( $index, $_ ) foreach @encoded; # Store index. unshift @indices, $index; } # translate base 24 "digits" to characters my $cd_key = join '', qw( B C D F G H J K M P Q R T V W X Y 2 3 4 6 7 8 9 )[ @indices ]; # Add seperators $cd_key = join '-', $cd_key =~ /(.{5})/g; return $cd_key; } sub quotient { use integer; my( $index, $encoded ) = @_; # Same as $index * 256 + $product_key ??? my $dividend = $index * 256 ^ $encoded; # return modulus and integer quotient return( $dividend % 24, $dividend / 24, ); }