crchash.cpp 905 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. ** Copyright (C) 2014 Wang Yaofu
  3. ** All rights reserved.
  4. **
  5. **Author:Wang Yaofu voipman@qq.com
  6. **Description: The source file of class CrcHash.
  7. */
  8. #include "crchash.h"
  9. #include "crc16.h"
  10. #include "crc32.h"
  11. #include "crc64.h"
  12. namespace common {
  13. uint16_t Hash16(const std::string& key)
  14. {
  15. return crc16(key.c_str(), key.size());
  16. }
  17. uint16_t Hash16(const char* cpKey, const int iKeyLen)
  18. {
  19. return crc16(cpKey, iKeyLen);
  20. }
  21. uint32_t Hash32(const std::string& key)
  22. {
  23. return crc32(key.c_str(), key.size());
  24. }
  25. uint32_t Hash32(const char* cpKey, const int iKeyLen)
  26. {
  27. return crc32(cpKey, iKeyLen);
  28. }
  29. uint64_t Hash64(const std::string& key)
  30. {
  31. return crc64(key.c_str(), key.size());
  32. }
  33. uint64_t Hash64(const char* cpKey, const int iKeyLen)
  34. {
  35. return crc64(cpKey, iKeyLen);
  36. }
  37. } // namespace common