Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #ifdef _WIN32
  6. #include <Windows.h>
  7. #else
  8. #include <unistd.h>
  9. #endif
  10.  
  11. int main()
  12. {
  13.     char userInput[15];
  14.     char *encryptedKey;
  15.     char doubleuserInput[30], firstarray[30], secondarray[30];
  16.     int i, iswrong;
  17.     int delaytime;
  18.     void delay(unsigned int);
  19.  
  20.     encryptedKey = "OHDSVXHIVAEBMRMXDPAAEIXTFQJZYB";
  21.  
  22.     delaytime = 1000;
  23.  
  24.     fgets(userInput, 16, stdin);
  25.  
  26. #ifdef _WIN32
  27. Sleep(delaytime);
  28. #else
  29. usleep(delaytime * 1000);
  30. #endif
  31.    
  32.    
  33.     for(i = 0; i < sizeof(doubleuserInput); i++)
  34.     {
  35.         doubleuserInput[i] = userInput[i%sizeof(userInput)];
  36.     }
  37.  
  38.     for(i = 0; i < sizeof(userInput); i++)
  39.     {
  40.         firstarray[2*i] = ((userInput[i] - 65 + 12)%26) + 65;
  41.         firstarray[2*i + 1] = ((userInput[i] - 65 + 15)%26) + 65;
  42.     }
  43.  
  44.     printf("\n");
  45.     for(i=0; i < sizeof(firstarray); i++)
  46.     {
  47.         secondarray[i] = (((firstarray[i] - 65) + (doubleuserInput[i] - 65)) % 26) + 65;
  48.     }
  49.  
  50.     for(i = 0; i < sizeof(secondarray); i++)
  51.     {
  52.         printf("%c", secondarray[i]);
  53.     }
  54.  
  55.     iswrong = 0;
  56.     for(i = 0; i < sizeof(secondarray); i++)
  57.     {
  58.         if(!(secondarray[i] == *(encryptedKey + i)))
  59.         {
  60.             iswrong = 1;
  61.         }
  62.     }
  63.  
  64.     if(iswrong == 1)
  65.         printf("Nop, dat is m niet");
  66.     if(iswrong == 0)
  67.         printf("Proof is in the key");
  68.  
  69.     return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement