代码拉取完成,页面将自动刷新
#ifndef __LOGV6_SDK_COMMON_H__
#define __LOGV6_SDK_COMMON_H__
#include <inttypes.h>
#include <iostream>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <vector>
#define SHA1_INPUT_WORDS 16
#define SHA1_DIGEST_WORDS 5
#define SHA1_INPUT_BYTES (SHA1_INPUT_WORDS*sizeof(uint32_t))
#define SHA1_DIGEST_BYTES (SHA1_DIGEST_WORDS*sizeof(uint32_t))
#define BIT_COUNT_WORDS 2
#define BIT_COUNT_BYTES (BIT_COUNT_WORDS*sizeof(uint32_t))
namespace aliyun_log_sdk_v6
{
/** Calculate Md5 for a byte stream,
* result is stored in md5[16]
*
* @param poolIn Input data
* @param inputBytesNum Length of input data
* @param md5[16] A 128-bit pool for storing md5
*/
void DoMd5(const uint8_t* poolIn, const uint64_t inputBytesNum, uint8_t md5[16]);
void Base64Encoding(std::istream&, std::ostream&, char makeupChar = '=',
const char *alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
class SHA1
{
public:
SHA1() : bits(0) {memcpy(H, IV, sizeof(H));}
SHA1(const SHA1& s)
{
bits=s.bits;
memcpy(H,s.H,sizeof(H));
memcpy(M,s.M,sizeof(M));
}
void init()
{
bits = 0;
memcpy(H, IV, sizeof(H));
}
void add(const uint8_t *data, size_t len);
uint8_t *result();
private:
uint64_t bits;
uint32_t H[SHA1_DIGEST_WORDS];
uint8_t M[SHA1_INPUT_BYTES];
static const uint32_t IV[SHA1_DIGEST_WORDS];
void transform();
};
class HMAC
{
public:
HMAC(const uint8_t *key, size_t lkey);
HMAC(const HMAC& hm) : in(hm.in), out(hm.out) {}
void init(const uint8_t *key, size_t lkey);
void add(const uint8_t *data, size_t len)
{
in.add(data, len);
}
uint8_t *result()
{
out.add(in.result(), SHA1_DIGEST_BYTES);
return out.result();
}
private:
SHA1 in, out;
};
class CompressAlgorithm
{
public:
static bool CompressLz4(const std::string& src, std::string& dst);
static bool CompressLz4(const char* srcPtr, const uint32_t srcSize, std::string& dest);
static bool UncompressLz4(const std::string& src, const uint32_t rawSize, std::string& dst);
static bool UncompressLz4(const char* srcPtr, const uint32_t srcSize, const uint32_t rawSize, std::string& dst);
};
std::string ToString(const int32_t& n);
std::string ToString(const uint32_t& n);
std::string ToString(const size_t&n);
std::string ToString(const time_t&n);
std::string ToString(const int64_t& n);
std::string ToString(const bool& n);
}
#endif
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。