-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFxms.h
66 lines (59 loc) · 1.92 KB
/
Fxms.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once
#include <cstdint>
#include <vector>
/**
* @brief The CFxms class provides encryption and decryption functionality using a specific algorithm.
*/
class CFxms {
public:
static constexpr uint64_t HashLen = sizeof(uint64_t), MaskLen = 16, KeyLen = 256;
/**
* @brief The Mode enum specifies the encryption or decryption mode.
*/
enum class Mode : int8_t {
OptimizeEncryption = 0, /**< Optimize encryption mode */
OptimizeDecryption = 1 /**< Optimize decryption mode */
};
/**
* @brief The Status enum specifies the status of the encryption or decryption operation.
*/
enum class Status : int8_t {
Success = 0, /**< Operation succeeded */
InvalidKeyLength = -1, /**< Invalid key length */
InvalidDataLength = -2, /**< Invalid data length */
DecryptionFailed = -3 /**< Decryption failed */
};
/**
* @brief Generates a random encryption key.
* @return A vector of bytes representing the generated key.
*/
static std::vector<uint8_t> GenKey();
/**
* @brief Encrypts the source data using the specified key and mode.
* @param key The encryption key.
* @param src The source data to be encrypted.
* @param dest The encrypted data.
* @param mode The encryption mode.
* @return The status of the encryption operation.
*/
static Status Encrypt(
const std::vector<uint8_t>& key,
const std::vector<uint8_t>& src,
std::vector<uint8_t>& dest,
Mode mode = Mode::OptimizeEncryption
);
/**
* @brief Decrypts the source data using the specified key and mode.
* @param key The decryption key.
* @param src The source data to be decrypted.
* @param dest The decrypted data.
* @param mode The decryption mode.
* @return The status of the decryption operation.
*/
static Status Decrypt(
const std::vector<uint8_t>& key,
std::vector<uint8_t> src,
std::vector<uint8_t>& dest,
Mode mode = Mode::OptimizeEncryption
);
};