View Single Post
  #6  
Old 01-17-2018, 02:28
dila dila is offline
Friend
 
Join Date: Jan 2010
Posts: 60
Rept. Given: 12
Rept. Rcvd 32 Times in 14 Posts
Thanks Given: 35
Thanks Rcvd at 74 Times in 20 Posts
dila Reputation: 32
Posting the code, since you expressed interest in it. Here we have the "encoder" which encodes a 6-bit integer (between 1 and 63) into the full serial. Note that we skip i=0 (and start at i=1) because the all-zero key is rejected by the routine, even though it is technically valid. There are no other valid keys.

I will spend some time thinking of a new challenge that is not so easy for UniSoft to solve next time

Code:
uint64_t generate(uint64_t x) {
  uint64_t y = 0;
  for (size_t i = 0; i < 64; ++i) {
    uint64_t u = x & i;
    uint64_t k = 0;
    for (size_t j = 0; j < 6; ++j) {
      k ^= (u >> j) & 1;
    }
    y |= k << i;
  }
  return y;
}

void print_keys() {
  for (size_t i = 1; i < 64; ++i) {
    uint64_t key = generate(i);
    if (check(key)) {
      std::cout << std::hex << key << std::endl;
    } else {
      std::cout << std::hex << key << " (BAD)" << std::endl;
    }
  }
}
Reply With Quote
The Following User Says Thank You to dila For This Useful Post:
tonyweb (01-18-2018)