Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkMD5.h
Go to the documentation of this file.
1/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkMD5_DEFINED
9#define SkMD5_DEFINED
10
14
15#include <cstdint>
16#include <cstring>
17
18/* Calculate a 128-bit MD5 message-digest of the bytes sent to this stream. */
19class SkMD5 : public SkWStream {
20public:
21 SkMD5();
22
23 /** Processes input, adding it to the digest.
24 Calling this after finish is undefined. */
25 bool write(const void* buffer, size_t size) final;
26
27 size_t bytesWritten() const final { return SkToSizeT(this->byteCount); }
28
29 struct Digest {
30 SkString toHexString() const;
32 bool operator==(Digest const& other) const {
33 return 0 == memcmp(data, other.data, sizeof(data));
34 }
35 bool operator!=(Digest const& other) const {
36 return !(*this == other);
37 }
38
39 uint8_t data[16];
40 };
41
42 /** Computes and returns the digest. */
43 Digest finish();
44
45private:
46 uint64_t byteCount; // number of bytes, modulo 2^64
47 uint32_t state[4]; // state (ABCD)
48 uint8_t buffer[64]; // input buffer
49};
50
51#endif
constexpr size_t SkToSizeT(S x)
Definition SkTo.h:31
Definition SkMD5.h:19
bool write(const void *buffer, size_t size) final
Definition SkMD5.cpp:42
Digest finish()
Definition SkMD5.cpp:72
size_t bytesWritten() const final
Definition SkMD5.h:27
SkMD5()
Definition SkMD5.cpp:34
SkString toHexString() const
Definition SkMD5.cpp:112
SkString toLowercaseHexString() const
Definition SkMD5.cpp:116
bool operator==(Digest const &other) const
Definition SkMD5.h:32
uint8_t data[16]
Definition SkMD5.h:39
bool operator!=(Digest const &other) const
Definition SkMD5.h:35