Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

@bKeyChars is being translated using ord() then translated back using chr(). The dashes can be added using a regex outside the first loop simplifying the outer loop. @bProductKey can be found without a need for @bDigitalProductID. The for loops can be rewritten to a more "perlish" style and we can step through @bProductKey without resorting to indexes. Finally, we can get rid of the Hungarian notation.

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 )[ @indice +s ]; # 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, ); }

This makes for a little cleaner look, not a speed increase. I tend more toward clean, maintainable code than fast code.

HTH,
Charles

In reply to Re: Finding Windows XP CD Key by CharlesClarkson
in thread Finding Windows XP CD Key by wgannon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-19 01:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found