Advertisement
Guest User

Untitled

a guest
Oct 13th, 2017
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main (int argc, char *argv[])
  6. {
  7.     if (argc < 2 || strlen(argv[1]) < 10) {
  8.         printf("./keygen 'yourname' (10 chars minimal)\n");
  9.         return 1;
  10.     }
  11.     char *name = argv[1];
  12.  
  13.     int j = 0xc0;
  14.     for (int i = 0; i < strlen(name); i++) {
  15.         char c = name[i];
  16.         c = c ^ j;
  17.         c = c & 3;
  18.         c = c << 1;
  19.  
  20.         switch(c) {
  21.             case 0:
  22.                 // Do nothing
  23.                 break;
  24.             case 2:
  25.                 name[i] = name[i] - c;
  26.                 break;
  27.             case 4:
  28.                 name[i] = name[i] ^ c;
  29.                 break;
  30.             case 6:
  31.                 name[i]= (c << 1) ^ name[i];
  32.                 break;
  33.             default:
  34.                 printf("Unexpected value encountered");
  35.                 return 1;
  36.         }
  37.         j += 1;
  38.         printf("%x", name[i]);
  39.     }
  40.     printf("\n");
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement