Enigma  3.2.0
A Simple, Reliable and Efficient Encryption Tool
Constants.hpp
Go to the documentation of this file.
1 #pragma once
2 #include "Types.hpp"
4 #include <array>
5 
6 namespace Enigma {
7  namespace Constants {
8  using namespace std::string_literals;
9 
10  static constexpr const std::uint16_t ENIGMA_SINGLE_PROCESS_UNIQUE_PORT = 36363; // unique app socket port used to avoid multiple instances
11  //static constexpr const auto ENIGMA_PACKAGE_NAME = "com.badereddineouaich.enigma"; // unique app id used to avoid multiple instances
12  //static constexpr const auto ENIGMA_MAGIC_NUMBER = 0x454e49474d41; // "ENIGMA"
13 
14  namespace Algorithm {
15  // Notes:
16  // GCM is defined for block ciphers with a block size of 128 bits. https://en.m.wikipedia.org/wiki/Galois/Counter_Mode
17  // No max password check since we're using KDF SHA-256, his allows you to use a password smaller or larger than the cipher's key size: https://crypto.stackexchange.com/questions/68299/length-of-password-requirement-using-openssl-aes-256-cbc
18  // Why GCM & EAX Modes: https://crypto.stackexchange.com/questions/18860/choice-of-authenticated-encryption-mode-for-whole-messages
19  // https://i.stack.imgur.com/0hNsK.jpg
20 
21  static constexpr const std::size_t MINIMUM_PASSWORD_LENGTH = 6; // AT LEAST 6 CHARACTERS, FOR SECURITY REASONS.
22  static constexpr const char *SPECIAL_CHARACTERS = R"(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)";
23 
24  namespace AES {
25  //https://www.cryptopp.com/wiki/GCM_Mode
26  }
27  namespace ChaCha20 {
28  // The ChaCha20 algorithm is a stream cipher using a key of 256 bit size.
29  // the ChaCha20 stream cipher does not have a block operation mode therefore it does not use padding.
30  //https://www.cryptopp.com/wiki/ChaCha20
31  }
32  namespace TripleDES {
33  //https://www.cryptopp.com/wiki/TripleDES
34  }
35  namespace Twofish {
36  //https://www.cryptopp.com/wiki/TWOFISH
37  }
38  namespace IDEA {
39  //https://www.cryptopp.com/wiki/IDEA
40  }
41  }
42 
43  namespace Database {
44  static const fs::path DATABASE_FILE_PATH = ::Enigma::ResourceManager::getResourcesDir() / "database" / "Enigma.db";
45  // Unfortunately, u cant create multiple tables at once..
46  static constexpr const std::array<std::string_view, 2> CREATE_TABLES_SQL = {
47  R"(
48  CREATE TABLE IF NOT EXISTS Encryptions
49  (
50  ide INTEGER PRIMARY KEY AUTOINCREMENT,
51  algo INTEGER NOT NULL, -- algorithm enum id used in encryption. e.g: AES=1 ..
52  title VARCHAR(255) NOT NULL,
53  date_time DATETIME NOT NULL,
54  size INTEGER NOT NULL, -- size of compressed cipher in bytes
55  is_file BOOLEAN NOT NULL,
56  file_ext VARCHAR(9), -- file extension to remember file type on decryption
57 
58  CHECK(LENGTH(title) <= 255) -- check title length <= 255
59  );
60  )",
61 
62  R"(
63  CREATE TABLE IF NOT EXISTS CipherChunks
64  (
65  idc INTEGER PRIMARY KEY AUTOINCREMENT,
66  ide INTEGER NOT NULL,
67  offset INTEGER NOT NULL,
68  size INTEGER NOT NULL,
69  bytes BLOB NOT NULL,
70 
71  FOREIGN KEY(ide) REFERENCES Encryptions(ide) ON DELETE CASCADE -- when an Encryption record is deleted, all associated Cipher records will also be deleted automatically.
72  );
73  )"
74 
75  };
76 
77  }
78 
79 #if TRANSLATION_ENABLED
80  namespace Translation {
81  static const fs::path TRANSLATION_DIR = "Translation";
82  static const fs::path TRANSLATION_CURRENT_FILE_PATH = fs::path(TRANSLATION_DIR) / ".current"; // application selected language to remember
83  static const fs::path TRANSLATION_ENGLISH_PATH = fs::path(TRANSLATION_DIR) / "English.ini";
84  }
85 #endif
86 
87  namespace CLI {
88  static constexpr const char *CLI_HELP_MESSAGE = "Say -h or --help to display available options";
89  }
90 
91  namespace Links {
92  static const auto ENIGMA_GITHUB_REPOSITORY = "https://github.com/baderouaich/Enigma"s;
93  static const auto ENIGMA_GITHUB_REPOSITORY_ISSUES = ENIGMA_GITHUB_REPOSITORY + "/issues"s;
94  static const auto ENIGMA_GITHUB_REPOSITORY_PULL_REQUESTS = ENIGMA_GITHUB_REPOSITORY + "/pulls"s;
95  static const auto ENIGMA_GITHUB_API = "https://api.github.com/repos/baderouaich/Enigma"s;
96  static const auto ENIGMA_GITHUB_API_LATEST_RELEASE = ENIGMA_GITHUB_API + "/releases/latest"s;
97  }
98 
99  namespace Resources {
100  // namespace Textures {
101  // // window runtime icon
102  // static const fs::path ENIGMA_LOGO_PNG_PATH = ::Enigma::ResourceManager::getResourcesDir() / "branding" / "Logo.png";
103  // }
104 
105  // namespace Fonts {
106  // static const fs::path AUDIOWIDE_FONT_PATH = ::Enigma::ResourceManager::getResourcesDir() / "fonts" / "Audiowide-Regular.ttf";
107  // static const fs::path MONTSERRAT_FONT_PATH = ::Enigma::ResourceManager::getResourcesDir() / "fonts" / "Montserrat-Medium.ttf";
108  // static const fs::path UBUNTU_FONT_PATH = ::Enigma::ResourceManager::getResourcesDir() / "fonts" / "Ubuntu-Regular.ttf";
109  // }
110  }
111 
112  namespace Colors {
113  static constexpr const auto COLOR4I_TO_COLOR4F = [](const float r, const float g, const float b, const float a) -> ImVec4 {
114  return ImVec4{r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f};
115  };
116 
117  static const ImVec4 RED(1.0f, 0.0f, 0.0f, 1.0f);
118  static const ImVec4 GREEN(0.0f, 1.0f, 0.0f, 1.0f);
119  static const ImVec4 BLUE(0.0f, 0.0f, 1.0f, 1.0f);
120  static const auto ORANGE = COLOR4I_TO_COLOR4F(255, 182, 0, 255);
121 
122  static const ImVec4 BACKGROUND_COLOR = COLOR4I_TO_COLOR4F(43, 43, 43, 255); // brown dark gray
123  //static const ImVec4 BACKGROUND_COLOR = COLOR4I_TO_COLOR4F(46, 53, 56, 255); // cyan dark gray
124  //static const ImVec4 BACKGROUND_COLOR = COLOR4I_TO_COLOR4F(46, 51, 56, 255); // blue dark gray
125 
126  static const ImVec4 TEXT_COLOR = COLOR4I_TO_COLOR4F(242, 242, 243, 225);
127  static const ImVec4 ERROR_TEXT_COLOR = COLOR4I_TO_COLOR4F(201, 46, 64, 255);
128  static const ImVec4 PASSWORD_MATCH_TEXT_COLOR = COLOR4I_TO_COLOR4F(94, 172, 161, 225);
129 
130 
131  static const ImVec4 BUTTON_COLOR = COLOR4I_TO_COLOR4F(10, 120, 122, 200);
132  static const ImVec4 BUTTON_COLOR_HOVER = COLOR4I_TO_COLOR4F(29, 188, 191, 200);
133  static const ImVec4 BUTTON_COLOR_ACTIVE = COLOR4I_TO_COLOR4F(11, 65, 66, 200); // PRESSSED
134 
135  static const ImVec4 MENUBAR_BACKGROUND_COLOR = COLOR4I_TO_COLOR4F(66, 66, 80, 200);
136 
137  static const ImVec4 BACK_BUTTON_COLOR = COLOR4I_TO_COLOR4F(209, 61, 86, 255);
138  static const ImVec4 BACK_BUTTON_COLOR_HOVER = COLOR4I_TO_COLOR4F(232, 81, 107, 255);
139  static const ImVec4 BACK_BUTTON_COLOR_ACTIVE = COLOR4I_TO_COLOR4F(150, 41, 59, 255);
140 
141  static const ImVec4 MY_ENCRYPTIONS_BUTTON_COLOR = COLOR4I_TO_COLOR4F(26, 72, 97, 255);
142  static const ImVec4 MY_ENCRYPTIONS_BUTTON_COLOR_HOVER = COLOR4I_TO_COLOR4F(38, 91, 120, 255);
143  static const ImVec4 MY_ENCRYPTIONS_BUTTON_COLOR_ACTIVE = COLOR4I_TO_COLOR4F(10, 132, 199, 255);
144 
145  static const ImVec4 TOOLS_BUTTON_COLOR = COLOR4I_TO_COLOR4F(25, 101, 130, 255);
146  static const ImVec4 TOOLS_BUTTON_COLOR_HOVER = COLOR4I_TO_COLOR4F(48, 146, 184, 255);
147  static const ImVec4 TOOLS_BUTTON_COLOR_ACTIVE = COLOR4I_TO_COLOR4F(60, 151, 186, 255);
148 
150  //static const ImVec4 LOADING_BACKGROUND_COLOR = { BACKGROUND_COLOR.x, BACKGROUND_COLOR.y, BACKGROUND_COLOR.z, 0.6f };
151  static const ImVec4 LOADING_BACKGROUND_COLOR = {0.0f, 0.0f, 0.0f, 0.8f};
152 
153 
155 
156 
157  }
158  }
159 }
Definition: AES.hpp:10
Algorithm abstract class.
Definition: Algorithm.hpp:53
static fs::path getResourcesDir()
Returns path to res/ folder Example: /home//Enigma/res/.
Definition: IDEA.hpp:11
static constexpr const char * CLI_HELP_MESSAGE
Definition: Constants.hpp:88
static constexpr const std::array< std::string_view, 2 > CREATE_TABLES_SQL
Definition: Constants.hpp:46
static const fs::path DATABASE_FILE_PATH
Definition: Constants.hpp:44
static constexpr const char * SPECIAL_CHARACTERS
Definition: Constants.hpp:22
static constexpr const std::size_t MINIMUM_PASSWORD_LENGTH
Definition: Constants.hpp:21
static const ImVec4 BACK_BUTTON_COLOR_ACTIVE
Definition: Constants.hpp:139
static const ImVec4 PASSWORD_MATCH_TEXT_COLOR
Definition: Constants.hpp:128
static const ImVec4 LOADING_BACKGROUND_COLOR
Definition: Constants.hpp:151
static const ImVec4 BACK_BUTTON_COLOR_HOVER
Definition: Constants.hpp:138
static const ImVec4 GREEN(0.0f, 1.0f, 0.0f, 1.0f)
static const ImVec4 MY_ENCRYPTIONS_BUTTON_COLOR
Definition: Constants.hpp:141
static const auto ORANGE
Definition: Constants.hpp:120
static const ImVec4 BUTTON_COLOR_ACTIVE
Definition: Constants.hpp:133
static const ImVec4 BACKGROUND_COLOR
Definition: Constants.hpp:122
static const ImVec4 MENUBAR_BACKGROUND_COLOR
Definition: Constants.hpp:135
static const ImVec4 MY_ENCRYPTIONS_BUTTON_COLOR_HOVER
Definition: Constants.hpp:142
static const ImVec4 TOOLS_BUTTON_COLOR_ACTIVE
Definition: Constants.hpp:147
static constexpr const auto COLOR4I_TO_COLOR4F
Definition: Constants.hpp:113
static const ImVec4 LOADING_SPINNER_COLOR
Definition: Constants.hpp:149
static const ImVec4 TOOLS_BUTTON_COLOR_HOVER
Definition: Constants.hpp:146
static const ImVec4 BACK_BUTTON_COLOR
Definition: Constants.hpp:137
static const ImVec4 & SCENE_TITLE_BACKGROUND_COLOR
Definition: Constants.hpp:154
static const ImVec4 TEXT_COLOR
Definition: Constants.hpp:126
static const ImVec4 BLUE(0.0f, 0.0f, 1.0f, 1.0f)
static const ImVec4 ERROR_TEXT_COLOR
Definition: Constants.hpp:127
static const ImVec4 BUTTON_COLOR_HOVER
Definition: Constants.hpp:132
static const ImVec4 TOOLS_BUTTON_COLOR
Definition: Constants.hpp:145
static const ImVec4 RED(1.0f, 0.0f, 0.0f, 1.0f)
static const ImVec4 MY_ENCRYPTIONS_BUTTON_COLOR_ACTIVE
Definition: Constants.hpp:143
static const ImVec4 BUTTON_COLOR
Definition: Constants.hpp:131
static constexpr const std::uint16_t ENIGMA_SINGLE_PROCESS_UNIQUE_PORT
Definition: Constants.hpp:10