MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
xor.hpp
1#ifndef MSTL_CORE_ENCRYPT_XOR_HPP__
2#define MSTL_CORE_ENCRYPT_XOR_HPP__
3#include "../string/string.hpp"
5
6class MSTL_API XOR {
7public:
8 static bstring encrypt(bstring_view data, bstring_view key);
9 static bstring decrypt(bstring_view data, bstring_view key) { return encrypt(data, key); }
10};
11
12
13MSTL_ALWAYS_INLINE_INLINE bstring xor_encrypt(const bstring& data, const bstring& key) {
14 return XOR::encrypt(data.view(), key.view());
15}
16MSTL_ALWAYS_INLINE_INLINE string xor_encrypt(const string& data, const string& key) {
17 return to_string(xor_encrypt(to_bstring(data), to_bstring(key)));
18}
19MSTL_ALWAYS_INLINE_INLINE bstring xor_decrypt(const bstring& data, const bstring& key) {
20 return XOR::decrypt(data.view(), key.view());
21}
22MSTL_ALWAYS_INLINE_INLINE string xor_decrypt(const string& data, const string& key) {
23 return to_string(xor_decrypt(to_bstring(data), to_bstring(key)));
24}
25
26MSTL_ALWAYS_INLINE_INLINE bstring xor_encrypt(const bstring_view data, const bstring_view key) {
27 return XOR::encrypt(data, key);
28}
29MSTL_ALWAYS_INLINE_INLINE bstring xor_decrypt(const bstring_view data, const bstring_view key) {
30 return XOR::decrypt(data, key);
31}
32
34#endif // MSTL_CORE_ENCRYPT_XOR_HPP__
#define MSTL_END_NAMESPACE__
结束全局命名空间MSTL
#define MSTL_BEGIN_NAMESPACE__
开始全局命名空间MSTL
MSTL_NODISCARD MSTL_ALWAYS_INLINE constexpr decltype(auto) data(Container &cont) noexcept(noexcept(cont.data()))
获取容器的底层数据指针