OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkMD5_DEFINED | 8 #ifndef SkMD5_DEFINED |
9 #define SkMD5_DEFINED | 9 #define SkMD5_DEFINED |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 return true; | 29 return true; |
30 } | 30 } |
31 | 31 |
32 size_t bytesWritten() const override { return SkToSizeT(this->byteCount); } | 32 size_t bytesWritten() const override { return SkToSizeT(this->byteCount); } |
33 | 33 |
34 /** Processes input, adding it to the digest. Calling this after finish is u
ndefined. */ | 34 /** Processes input, adding it to the digest. Calling this after finish is u
ndefined. */ |
35 void update(const uint8_t* input, size_t length); | 35 void update(const uint8_t* input, size_t length); |
36 | 36 |
37 struct Digest { | 37 struct Digest { |
38 uint8_t data[16]; | 38 uint8_t data[16]; |
| 39 bool operator ==(Digest const& other) const { |
| 40 return 0 == memcmp(data, other.data, sizeof(data)); |
| 41 } |
| 42 bool operator !=(Digest const& other) const { |
| 43 return 0 != memcmp(data, other.data, sizeof(data)); |
| 44 } |
39 }; | 45 }; |
40 | 46 |
41 /** Computes and returns the digest. */ | 47 /** Computes and returns the digest. */ |
42 void finish(Digest& digest); | 48 void finish(Digest& digest); |
43 | 49 |
44 private: | 50 private: |
45 // number of bytes, modulo 2^64 | 51 // number of bytes, modulo 2^64 |
46 uint64_t byteCount; | 52 uint64_t byteCount; |
47 | 53 |
48 // state (ABCD) | 54 // state (ABCD) |
49 uint32_t state[4]; | 55 uint32_t state[4]; |
50 | 56 |
51 // input buffer | 57 // input buffer |
52 uint8_t buffer[64]; | 58 uint8_t buffer[64]; |
53 }; | 59 }; |
54 | 60 |
55 #endif | 61 #endif |
OLD | NEW |