| 1 | /* |
| 2 | * LegacyClonk |
| 3 | * |
| 4 | * Copyright (c) 2017-2019, The LegacyClonk Team and contributors |
| 5 | * |
| 6 | * Distributed under the terms of the ISC license; see accompanying file |
| 7 | * "COPYING" for details. |
| 8 | * |
| 9 | * "Clonk" is a registered trademark of Matthes Bender, used with permission. |
| 10 | * See accompanying file "TRADEMARK" for details. |
| 11 | * |
| 12 | * To redistribute this file separately, substitute the full license texts |
| 13 | * for the above references. |
| 14 | */ |
| 15 | |
| 16 | #pragma once |
| 17 | |
| 18 | #include <cstddef> |
| 19 | #include <memory> |
| 20 | |
| 21 | // SHA-1 calculation |
| 22 | class StdSha1 |
| 23 | { |
| 24 | public: |
| 25 | static const size_t DigestLength = 20; |
| 26 | |
| 27 | StdSha1(); |
| 28 | ~StdSha1(); |
| 29 | // Adds the specified buffer to the data to be hashed. |
| 30 | void Update(const void *buffer, std::size_t len); |
| 31 | /* Returns the calculated hash. |
| 32 | * After calling, do not call Update without calling Reset first. */ |
| 33 | void GetHash(void *result); |
| 34 | // Discards the current hash so another hash can be calculated. |
| 35 | void Reset(); |
| 36 | |
| 37 | private: |
| 38 | struct Impl; |
| 39 | const std::unique_ptr<Impl> impl; |
| 40 | }; |
| 41 | |