Guest User

Untitled

a guest
Dec 16th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdlib>
  4.  
  5. using namespace std;
  6.  
  7. void decrypt(const unsigned int R)
  8. {
  9. int a;
  10. int b;
  11. unsigned int r;
  12.  
  13. srand(R);
  14.  
  15. FILE* A = fopen("code.txt","r");
  16. FILE* B = fopen("output.txt","w");
  17.  
  18. a = fgetc(A);
  19.  
  20. while(a != EOF)
  21. {
  22. r = rand();
  23.  
  24. if (a<32)
  25. {
  26. b = a;
  27. }
  28. else if (a>=32)
  29. {
  30. b = (a-32-(r%(128-32)))%(128+32)+32;
  31. }
  32.  
  33. fputc(b, B);
  34.  
  35. a = fgetc(A);
  36. }
  37.  
  38. fclose(A);
  39. fclose(B);
  40. }
  41.  
  42.  
  43.  
  44. int main()
  45. {
  46. int a;
  47. int b;
  48. int characters = 70;
  49. unsigned int r;
  50. fpos_t pos;
  51. FILE* A = fopen("code.txt","r");
  52. fgetpos(A,&pos);
  53. for (int i=4000000000; i<=4294967295; i++)
  54. {
  55. unsigned int R = i;
  56. srand(R);
  57. a = fgetc(A);
  58.  
  59. for (int x=0; x<=characters; x++)
  60. {
  61. r = rand();
  62.  
  63. if (a<32)
  64. {
  65. b = a;
  66. }
  67. else if (a>=32)
  68. {
  69. b = (a-32-(r%(128-32)))%(128+32)+32;
  70. }
  71.  
  72. if ( (x==0) && (b < 65 || b > 90) )
  73. {
  74. break;
  75. }
  76.  
  77. if ((x > 0) && (b!=32) && ( (b < 97) || (b > 122) ) && (b < 65 || b > 90) && (b!=44) && (b!=45) && (b!=46) && (b!=10))
  78. {
  79. break;
  80. }
  81. if (x==characters)
  82. {
  83. cout << R << endl;
  84. decrypt(R);
  85. break;
  86. }
  87.  
  88. a = fgetc(A);
  89. }
  90.  
  91. fsetpos(A,&pos);
  92.  
  93. }
  94.  
  95. return 0;
  96. }
Add Comment
Please, Sign In to add comment