Files
2026-06-30 17:46:34 +08:00

94 lines
2.2 KiB
C++

#pragma once
#include <string>
#include <rhash.h>
#include <cstdint>
#include <json/json.h>
#pragma warning(disable : 4251)
#pragma warning(disable : 4996)
#ifdef UOHASH_EXPORTS
#define UOHASH_DLL_API __declspec(dllexport)
#else
#define UOHASH_DLL_API __declspec(dllimport)
#ifdef _DEBUG
#pragma comment(lib, "../x64/Debug/UOHashd.lib")
#else
#pragma comment(lib, "../x64/Release/UOHash.lib")
#endif
#endif
namespace uns
{
enum class UOHASH_DLL_API HashID : std::int64_t
{
CRC32 = RHASH_CRC32,
MD4 = RHASH_MD4,
MD5 = RHASH_MD5,
SHA1 = RHASH_SHA1,
TIGER = RHASH_TIGER,
TTH = RHASH_TTH,
BTIH = RHASH_BTIH,
ED2K = RHASH_ED2K,
AICH = RHASH_AICH,
WHIRLPOOL = RHASH_WHIRLPOOL,
RIPEMD160 = RHASH_RIPEMD160,
GOST94 = RHASH_GOST94,
GOST94_CRYPTOPRO = RHASH_GOST94_CRYPTOPRO,
HAS160 = RHASH_HAS160,
GOST12_256 = RHASH_GOST12_256,
GOST12_512 = RHASH_GOST12_512,
SHA224 = RHASH_SHA224,
SHA256 = RHASH_SHA256,
SHA384 = RHASH_SHA384,
SHA512 = RHASH_SHA512,
EDONR256 = RHASH_EDONR256,
EDONR512 = RHASH_EDONR512,
SHA3_224 = RHASH_SHA3_224,
SHA3_256 = RHASH_SHA3_256,
SHA3_384 = RHASH_SHA3_384,
SHA3_512 = RHASH_SHA3_512,
CRC32C = RHASH_CRC32C,
SNEFRU128 = RHASH_SNEFRU128,
SNEFRU256 = RHASH_SNEFRU256,
BLAKE2S = RHASH_BLAKE2S,
BLAKE2B = RHASH_BLAKE2B, //0x40000000
__RHASH_MAX = 0b01111111111111111111111111111111,
SHAKE128 = 0x80000000,
SHAKE256 = 0x100000000,
BASE16 = 0x200000000,
BASE32 = 0x400000000,
BASE32_HEX = 0x800000000,
BASE36 = 0x1000000000,
BASE58 = 0x2000000000,
BASE62 = 0x4000000000,
BASE64 = 0x8000000000,
BASE64_URL = 0x10000000000,
BASE85 = 0x20000000000,
BASE91 = 0x40000000000,
URL = 0x80000000000
};
class UOHASH_DLL_API HashResult
{
private:
bool success;
std::string result;
std::string last_error;
public:
HashResult();
HashResult(std::string res);
HashResult(const HashResult& obj);
HashResult(bool succ, std::string res, std::string err);
public:
static HashResult Faliure(std::string str);
static HashResult Success(std::string str);
public:
std::string GetResult();
std::string GetLastError();
std::string EncodeJsonString(bool unicode = false, bool styled = false);
public:
operator bool();
operator std::string();
operator Json::Value();
};
};