diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /gfx/skia/skia/src/core/SkMD5.h | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/skia/skia/src/core/SkMD5.h')
-rw-r--r-- | gfx/skia/skia/src/core/SkMD5.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/gfx/skia/skia/src/core/SkMD5.h b/gfx/skia/skia/src/core/SkMD5.h new file mode 100644 index 0000000000..10cacf188b --- /dev/null +++ b/gfx/skia/skia/src/core/SkMD5.h @@ -0,0 +1,45 @@ +/* + * Copyright 2012 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkMD5_DEFINED +#define SkMD5_DEFINED + +#include "include/core/SkStream.h" +#include "include/private/base/SkTo.h" + +#include <cstdint> +#include <cstring> + +/* Calculate a 128-bit MD5 message-digest of the bytes sent to this stream. */ +class SkMD5 : public SkWStream { +public: + SkMD5(); + + /** Processes input, adding it to the digest. + Calling this after finish is undefined. */ + bool write(const void* buffer, size_t size) final; + + size_t bytesWritten() const final { return SkToSizeT(this->byteCount); } + + struct Digest { + uint8_t data[16]; + bool operator ==(Digest const& other) const { + return 0 == memcmp(data, other.data, sizeof(data)); + } + bool operator !=(Digest const& other) const { return !(*this == other); } + }; + + /** Computes and returns the digest. */ + Digest finish(); + +private: + uint64_t byteCount; // number of bytes, modulo 2^64 + uint32_t state[4]; // state (ABCD) + uint8_t buffer[64]; // input buffer +}; + +#endif |