STTNet
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 宏定义 
静态 Public 成员函数 | 所有成员列表
stt::data::CryptoUtil类 参考

负责加密,解密和哈希 更多...

#include <sttnet.h>

静态 Public 成员函数

static bool encryptSymmetric (const unsigned char *before, const size_t &length, const unsigned char *passwd, const unsigned char *iv, unsigned char *after)
 AES-256-CBC模式对称加密函数 更多...
 
static bool decryptSymmetric (const unsigned char *before, const size_t &length, const unsigned char *passwd, const unsigned char *iv, unsigned char *after)
 AES-256-CBC模式对称解密函数 更多...
 
static std::string & sha1 (const std::string &ori_str, std::string &result)
 计算输入字符串的 SHA-1 哈希值(原始二进制形式)。 更多...
 
static std::string & sha11 (const std::string &ori_str, std::string &result)
 计算输入字符串的 SHA-1 哈希值,并以十六进制字符串形式返回。 更多...
 

详细描述

负责加密,解密和哈希

成员函数说明

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

AES-256-CBC模式对称解密函数

参数
before密文的数据容器
length密文的数据长度
passwd密钥
iviv向量
after解密后的数据容器
返回
true:解密成功 false:解密失败
注解
AES-256-CBC模式下 密钥为32字节 iv向量为16字节
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

AES-256-CBC模式对称加密函数

参数
before加密前的数据容器
length数据前的数据长度
passwd密钥
iviv向量
after密文的数据容器
返回
true:加密成功 false:加密失败
注解
AES-256-CBC模式下 密钥为32字节 iv向量为16字节
static std::string& stt::data::CryptoUtil::sha1 ( const std::string &  ori_str,
std::string &  result 
)
static

计算输入字符串的 SHA-1 哈希值(原始二进制形式)。

使用 OpenSSL 的 SHA1 函数对输入字符串进行哈希处理,结果以 20 字节的原始二进制形式存储在 result 中。 注意:result 可能包含不可打印字符,不适合直接输出或写入文本。

参数
ori_str输入的原始字符串。
result用于存放输出的 SHA-1 哈希值(二进制形式),长度为 20 字节。
返回
返回 result 的引用。
注解
该函数适用于后续加密、签名等处理(例如用于 HMAC 的输入)。
static std::string& stt::data::CryptoUtil::sha11 ( const std::string &  ori_str,
std::string &  result 
)
static

计算输入字符串的 SHA-1 哈希值,并以十六进制字符串形式返回。

使用 OpenSSL 的 SHA1 函数对输入字符串进行哈希处理,结果以 40 个字符的十六进制格式表示存储在 result 中。 每个字节转换为两个十六进制字符,可直接用于打印、日志记录、存储等可读场景。

参数
ori_str输入的原始字符串。
result用于存放输出的 SHA-1 哈希值(40 字节的十六进制字符串)。
返回
返回 result 的引用。
注解
适用于哈希显示、唯一标识、日志校验等场景。与 sha1 的主要区别是输出格式。

该类的文档由以下文件生成: