Responsible for encryption, decryption, and hashing.
More...
#include <sttnet_English.h>
|
| static bool | encryptSymmetric (const unsigned char *before, const size_t &length, const unsigned char *passwd, const unsigned char *iv, unsigned char *after) |
| | Symmetric encryption function in AES-256-CBC mode. More...
|
| |
| static bool | decryptSymmetric (const unsigned char *before, const size_t &length, const unsigned char *passwd, const unsigned char *iv, unsigned char *after) |
| | Symmetric decryption function in AES-256-CBC mode. More...
|
| |
| static std::string & | sha1 (const std::string &ori_str, std::string &result) |
| | Calculate the SHA-1 hash value (raw binary form) of the input string. More...
|
| |
| static std::string & | sha11 (const std::string &ori_str, std::string &result) |
| | Calculate the SHA-1 hash value of the input string and return it as a hexadecimal string. More...
|
| |
Responsible for encryption, decryption, and hashing.
| static bool stt::data::CryptoUtil::decryptSymmetric |
( |
const unsigned char * |
before, |
|
|
const size_t & |
length, |
|
|
const unsigned char * |
passwd, |
|
|
const unsigned char * |
iv, |
|
|
unsigned char * |
after |
|
) |
| |
|
static |
Symmetric decryption function in AES-256-CBC mode.
- Parameters
-
| before | Data container for ciphertext |
| length | Length of the ciphertext |
| passwd | Decryption key |
| iv | IV vector |
| after | Data container for decrypted data |
- Returns
- true: Decryption successful, false: Decryption failed
- Note
- In AES-256-CBC mode, the key is 32 bytes and the iv vector is 16 bytes
| static bool stt::data::CryptoUtil::encryptSymmetric |
( |
const unsigned char * |
before, |
|
|
const size_t & |
length, |
|
|
const unsigned char * |
passwd, |
|
|
const unsigned char * |
iv, |
|
|
unsigned char * |
after |
|
) |
| |
|
static |
Symmetric encryption function in AES-256-CBC mode.
- Parameters
-
| before | Data container before encryption |
| length | Length of the data |
| passwd | Encryption key |
| iv | IV vector |
| after | Data container for ciphertext |
- Returns
- true: Encryption successful, false: Encryption failed
- Note
- In AES-256-CBC mode, the key is 32 bytes and the iv vector is 16 bytes
| static std::string& stt::data::CryptoUtil::sha1 |
( |
const std::string & |
ori_str, |
|
|
std::string & |
result |
|
) |
| |
|
static |
Calculate the SHA-1 hash value (raw binary form) of the input string.
Uses OpenSSL's SHA1 function to hash the input string, and the result is stored in result in 20-byte raw binary form. Note: result may contain non-printable characters and is not suitable for direct output or writing to text.
- Parameters
-
| ori_str | Input original string. |
| result | Used to store the output SHA-1 hash value (binary form), 20 bytes in length. |
- Returns
- Reference to result.
- Note
- This function is suitable for subsequent encryption, signature, etc. (e.g., for HMAC input).
| static std::string& stt::data::CryptoUtil::sha11 |
( |
const std::string & |
ori_str, |
|
|
std::string & |
result |
|
) |
| |
|
static |
Calculate the SHA-1 hash value of the input string and return it as a hexadecimal string.
Uses OpenSSL's SHA1 function to hash the input string, and the result is stored in result in a 40-character hexadecimal format. Each byte is converted to two hexadecimal characters, which can be directly used for readable scenarios such as printing, logging, and storage.
- Parameters
-
| ori_str | Input original string. |
| result | Used to store the output SHA-1 hash value (40-byte hexadecimal string). |
- Returns
- Reference to result.
- Note
- Suitable for hash display, unique identification, log verification, etc. The main difference from sha1 is the output format.
The documentation for this class was generated from the following file: