mainwindow.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3. #include <QCryptographicHash>
  4. #include <QMainWindow>
  5. #include <QProcess>
  6. #include <QRegularExpression>
  7. #include "QDebug"
  8. #include <QFile>
  9. #include <QTimer>
  10. QT_BEGIN_NAMESPACE
  11. namespace Ui { class MainWindow; }
  12. QT_END_NAMESPACE
  13. class MainWindow : public QMainWindow
  14. {
  15. Q_OBJECT
  16. public:
  17. MainWindow(QWidget *parent = nullptr);
  18. ~MainWindow();
  19. private slots:
  20. void on_pushButton_clicked();
  21. void on_pushButton_2_clicked();
  22. private:
  23. Ui::MainWindow *ui;
  24. QString hashString(const QString &str) {
  25. QString strippedStr = str;
  26. strippedStr.remove(QChar('-'));
  27. QByteArray hashData = QCryptographicHash::hash(strippedStr.toUtf8(), QCryptographicHash::Sha256);
  28. QString hashedStr = QString::fromLatin1(hashData.toHex());
  29. return hashedStr;
  30. }
  31. QString caesarCipher(const QString &text, int shift) {
  32. QString result;
  33. const int alphabetSize = 26;
  34. const int digitSize = 10;
  35. for (const QChar &ch : text) {
  36. if (ch.isLetter()) {
  37. QChar base = ch.isLower() ? 'a' : 'A';
  38. result.append(QChar((ch.toLatin1() - base.toLatin1() + shift + alphabetSize) % alphabetSize + base.toLatin1()));
  39. } else if (ch.isDigit()) {
  40. result.append(QChar((ch.toLatin1() - '0' + shift + digitSize) % digitSize + '0'));
  41. } else {
  42. result.append(ch);
  43. }
  44. }
  45. return result;
  46. }
  47. };
  48. #endif // MAINWINDOW_H