duckstation

duckstation, but archived from the revision just before upstream changed it to a proprietary software project, this version is the libre one
git clone https://git.neptards.moe/u3shit/duckstation.git
Log | Files | Refs | README | LICENSE

sha1_digest.h (747B)


      1 // SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
      2 // SPDX-License-Identifier: (GPL-3.0 OR PolyForm-Strict-1.0.0)
      3 
      4 #pragma once
      5 
      6 #include "types.h"
      7 
      8 #include <array>
      9 #include <string>
     10 #include <span>
     11 
     12 class SHA1Digest
     13 {
     14 public:
     15   enum : u32
     16   {
     17     DIGEST_SIZE = 20
     18   };
     19 
     20   SHA1Digest();
     21 
     22   void Update(const void* data, size_t len);
     23   void Update(std::span<const u8> data);
     24   void Final(u8 digest[DIGEST_SIZE]);
     25   void Reset();
     26 
     27   static std::string DigestToString(const std::span<u8, DIGEST_SIZE> digest);
     28 
     29   static std::array<u8, DIGEST_SIZE> GetDigest(const void* data, size_t len);
     30   static std::array<u8, DIGEST_SIZE> GetDigest(std::span<const u8> data);
     31 
     32 private:
     33   u32 state[5];
     34   u32 count[2];
     35   u8 buffer[64];
     36 };