NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
sha256.hpp
浏览该文件的文档.
1#ifndef NEFORCE_CORE_ENCRYPT_SHA256_HPP__
2#define NEFORCE_CORE_ENCRYPT_SHA256_HPP__
3
11
14NEFORCE_BEGIN_NAMESPACE__
15
20
82
89struct NEFORCE_API SHA256 {
96
102 static string hash_hex(cbyte_view data);
103};
104
105
111NEFORCE_ALWAYS_INLINE_INLINE string sha256(const string_view data) {
112 return SHA256::hash_hex({reinterpret_cast<const byte_t*>(data.data()), data.size()});
113}
114
120NEFORCE_ALWAYS_INLINE_INLINE string sha256(const string& data) {
121 return SHA256::hash_hex({reinterpret_cast<const byte_t*>(data.data()), data.size()});
122}
123
129NEFORCE_ALWAYS_INLINE_INLINE byte_vector sha256(const cbyte_view data) { return SHA256::hash(data); }
130
136NEFORCE_ALWAYS_INLINE_INLINE byte_vector sha256(const byte_vector& data) { return SHA256::hash(data.view()); }
137 // Encryption
139
140NEFORCE_END_NAMESPACE__
141#endif // NEFORCE_CORE_ENCRYPT_SHA256_HPP__
vector< byte_t > byte_vector
字节向量类型别名
unsigned char byte_t
字节类型,定义为无符号字符
static byte_vector hash(cbyte_view data)
计算SHA-256哈希值
static string hash_hex(cbyte_view data)
计算SHA-256哈希值的十六进制表示
memory_view< const byte_t > cbyte_view
常量字节视图类型别名
NEFORCE_ALWAYS_INLINE_INLINE string sha256(const string_view data)
SHA-256哈希便捷函数(字符串视图版本)
basic_string_view< char > string_view
字符字符串视图
NEFORCE_NODISCARD NEFORCE_ALWAYS_INLINE constexpr decltype(auto) data(Container &cont) noexcept(noexcept(cont.data()))
获取容器的底层数据指针
字符串类型别名和实用函数
SHA-256哈希算法结构体
动态大小数组容器