mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-20 19:52:12 +00:00
Introduce std::string_view
into wider use (#14368)
This commit is contained in:
parent
fa47af737f
commit
6ca214fefc
74 changed files with 501 additions and 456 deletions
|
@ -26,7 +26,11 @@ SOFTWARE.
|
|||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned int Uint32;
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
typedef uint32_t Uint32;
|
||||
|
||||
class SHA1
|
||||
{
|
||||
|
@ -38,15 +42,24 @@ private:
|
|||
Uint32 H3 = 0x10325476;
|
||||
Uint32 H4 = 0xc3d2e1f0;
|
||||
unsigned char bytes[64];
|
||||
int unprocessedBytes = 0;
|
||||
Uint32 unprocessedBytes = 0;
|
||||
Uint32 size = 0;
|
||||
void process();
|
||||
|
||||
public:
|
||||
SHA1();
|
||||
~SHA1();
|
||||
void addBytes(const char *data, int num);
|
||||
unsigned char *getDigest();
|
||||
void addBytes(const char *data, Uint32 num);
|
||||
inline void addBytes(std::string_view data) {
|
||||
addBytes(data.data(), data.size());
|
||||
}
|
||||
void getDigest(unsigned char *to);
|
||||
inline std::string getDigest() {
|
||||
std::string ret(20, '\000');
|
||||
getDigest(reinterpret_cast<unsigned char*>(ret.data()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
// utility methods
|
||||
static Uint32 lrot(Uint32 x, int bits);
|
||||
static void storeBigEndianUint32(unsigned char *byte, Uint32 num);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue