-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rc4.h
37 lines (33 loc) · 1.07 KB
/
Rc4.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
#pragma once
#include <cstdint>
/**
* @brief The CRc4 class represents the RC4 encryption algorithm.
*/
class CRc4 {
public:
/**
* @brief The CContext class represents the context of the RC4 encryption algorithm.
*/
class CContext {
public:
uint8_t state[256]; ///< The state array used in the RC4 algorithm.
uint8_t x; ///< The x variable used in the RC4 algorithm.
uint8_t y; ///< The y variable used in the RC4 algorithm.
};
/**
* @brief Initializes the RC4 encryption algorithm with the given key.
*
* @param a4i Pointer to the CContext object.
* @param key Pointer to the key.
* @param keyLen Length of the key.
*/
static void Init(CContext* a4i, const void* key, uint32_t keyLen);
/**
* @brief Encrypts or decrypts the given string using the RC4 encryption algorithm.
*
* @param a4i Pointer to the CContext object.
* @param inoutString Pointer to the string to be encrypted or decrypted.
* @param length Length of the string.
*/
static void Crypt(CContext* a4i, void* inoutString, uint32_t length);
};