This commit is contained in:
xx
2024-06-14 17:44:36 +08:00
parent a3c4b6bfaf
commit b20ac2a4a8
9 changed files with 423 additions and 39 deletions

View File

@@ -8,6 +8,9 @@
// 是否DEBUG调试内存申请情况
#define DEBUG_MEM 0
#define USE_OPENSSL 0
using namespace ylib;
// 斜杆

53
include/util/md5.h Normal file
View File

@@ -0,0 +1,53 @@
// MD5.h
#ifndef BZF_MD5_H
#define BZF_MD5_H
#include <iostream>
#include <string>
#include "base/buffer.h"
namespace ylib
{
class MD5
{
public:
typedef unsigned int size_type; // must be 32bit
MD5();
MD5(const ylib::buffer& value);
void update(const unsigned char* buf, size_type length);
void update(const char* buf, size_type length);
MD5& finalize();
std::string hexdigest() const;
friend std::ostream& operator<<(std::ostream&, MD5 md5);
private:
void init();
typedef unsigned char uint1; // 8bit
typedef unsigned int uint4; // 32bit
enum { blocksize = 64 }; // VC6 won't eat a const static int here
void transform(const uint1 block[blocksize]);
static void decode(uint4 output[], const uint1 input[], size_type len);
static void encode(uint1 output[], const uint4 input[], size_type len);
bool finalized;
uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk
uint4 count[2]; // 64bit counter for number of bits (lo, hi)
uint4 state[4]; // digest so far
uint1 digest[16]; // the result
// low level logic operations
static inline uint4 F(uint4 x, uint4 y, uint4 z);
static inline uint4 G(uint4 x, uint4 y, uint4 z);
static inline uint4 H(uint4 x, uint4 y, uint4 z);
static inline uint4 I(uint4 x, uint4 y, uint4 z);
static inline uint4 rotate_left(uint4 x, int n);
static inline void FF(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
static inline void GG(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
static inline void HH(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
static inline void II(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
};
}
#endif

View File

@@ -1,5 +1,5 @@
#pragma once
#include "sqlite3/sqlite3.h"
#include "base/define.h"
#include "base/error.h"
#include <vector>
@@ -20,6 +20,6 @@ namespace ylib
bool is_open() { return m_db != nullptr; }
int64 last_insert_id();
private:
struct ::sqlite3* m_db;
void* m_db;
};
}