djb2.cc 439 B

1234567891011121314
  1. // Copyright (c) 2012 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. #include "media/base/djb2.h"
  5. uint32_t DJB2Hash(const void* buf, size_t len, uint32_t seed) {
  6. const uint8_t* src = reinterpret_cast<const uint8_t*>(buf);
  7. uint32_t hash = seed;
  8. for (size_t i = 0; i < len; ++i) {
  9. hash = hash * 33 + src[i];
  10. }
  11. return hash;
  12. }