md5_constexpr.h 1.0 KB

123456789101112131415161718192021222324252627
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_HASH_MD5_CONSTEXPR_H_
  5. #define BASE_HASH_MD5_CONSTEXPR_H_
  6. #include "base/hash/md5_constexpr_internal.h"
  7. namespace base {
  8. // Calculates the first 32/64 bits of the MD5 digest of the provided data,
  9. // returned as a uint32_t/uint64_t. When passing |string| with no explicit
  10. // length the terminating null will not be processed. This abstracts away
  11. // endianness so that the integer will read as the first 4 or 8 bytes of the
  12. // MD5 sum, ensuring that the following outputs are equivalent for
  13. // convenience:
  14. //
  15. // printf("%08x\n", MD5Hash32Constexpr("foo"));
  16. constexpr uint64_t MD5Hash64Constexpr(const char* string);
  17. constexpr uint64_t MD5Hash64Constexpr(const char* data, uint32_t length);
  18. constexpr uint32_t MD5Hash32Constexpr(const char* string);
  19. constexpr uint32_t MD5Hash32Constexpr(const char* data, uint32_t length);
  20. } // namespace base
  21. #endif // BASE_HASH_MD5_CONSTEXPR_H_