cipher.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * я хз зачем это сделал
  3. *
  4. * meow => ~omm
  5. * the test phrase => acubld pced uh`
  6. * тестовая фраза => 070QpPx>5
  7. *
  8. * оно не любит киррилицу
  9. */
  10. #include <stdio.h>
  11. #include <string.h>
  12. int main(int argc, char* argv[])
  13. {
  14. if (argc <= 1)
  15. return 1;
  16. const char* src = argv[1];
  17. const int src_len = strlen(src);
  18. unsigned int sum = 0;
  19. for (int i = 0; i < src_len; i++)
  20. sum += src[i];
  21. for (int i = 0; i < src_len; i++) {
  22. unsigned char step1 = (src[i] ^ sum) | ~src[i] ^ 0b11110000;
  23. unsigned char step2 = step1 | src[i] & 0b11110000;
  24. unsigned char step3 = (step2 ^ (~src[src_len - i - 1] & 0x7f));
  25. if (step3 < 31)
  26. step3 += src[src_len - i - 1] & 0b00001111;
  27. if (step3 > 127)
  28. step3 ^= 0b10000000;
  29. if (step3 == 127)
  30. step3--;
  31. /* printf("(step1 %d) (step2 %d) (step3 %d)\n", step1, step2, step3); */
  32. putchar(step3);
  33. }
  34. puts("");
  35. }