1
0
Fork 0
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:
sfan5 2024-02-17 15:35:33 +01:00 committed by GitHub
parent fa47af737f
commit 6ca214fefc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
74 changed files with 501 additions and 456 deletions

View file

@ -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);