Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <cstdlib>
- #include <cstring>
- #include <windows.h> // Sleep
- bool is_encrypted(const char *s, unsigned long seed)
- {
- srand(seed);
- size_t len = strlen(s);
- unsigned int i; for(i = 0; i < len; ++i)
- {
- if( (rand() % 27 + 'a') != s[i] )
- return false;
- }
- return rand() % 27 == 26; //26 is the new \0
- }
- int main()
- {
- const char *data = "ayyyy";
- unsigned long seed = -1;
- clock_t before = clock();
- do
- {
- if ( ++seed == (unsigned long)(-1) ) exit(1);
- }
- while( !is_encrypted(data, seed) );
- clock_t after = clock();
- double seconds_took = (double)(after - before) / CLOCKS_PER_SEC;
- system("color 0a");
- printf("Encryption took only %.2fs!\n", seconds_took);
- printf("Here's your TOP SECRET KEY: %lu\n", seed);
- printf("Decrypting");
- putchar('.'); Sleep(500);
- putchar('.'); Sleep(500);
- putchar('.'); Sleep(500);
- putchar('\n');
- srand(seed);
- char c, *ptr, decrypted[256]; //Does it need to be bigger? ¯\_(ツ)_/¯
- ptr = &decrypted[0];
- while( (c = rand() % 27 + 'a') != ('z' + 1) ) *ptr++ = c;
- *ptr = '\0';
- printf("Decrypted text: %s", decrypted);
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement