诸暨麻将添加redis
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

64 wiersze
1.6 KiB

  1. // ***********************************************************************
  2. // Filename : SHA1.h
  3. // Author : LIZHENG
  4. // Created : 2015--27
  5. // Description : 安全哈希算法(Secure Hash Algorithm)
  6. //
  7. // Last Modified By : LIZHENG
  8. // Last Modified On : 2015-11-10
  9. //
  10. // Copyright (c) lizhenghn@gmail.com. All rights reserved.
  11. // ***********************************************************************
  12. #ifndef ZL_SHA1_H
  13. #define ZL_SHA1_H
  14. #include <string>
  15. #include <stdint.h>
  16. // 对于长度小于2^64位的消息,SHA1会产生一个160位的消息摘要。当接收到消息的时候,这个消息摘要可以用来验证数据的完整性。
  17. // 在传输的过程中,数据很可能会发生变化,那么这时候就会产生不同的消息摘要。
  18. // SHA1特性:不可以从消息摘要中复原信息;两个不同的消息不会产生同样的消息摘要。
  19. namespace zl
  20. {
  21. namespace util
  22. {
  23. class SHA1
  24. {
  25. public:
  26. SHA1();
  27. ~SHA1();
  28. static std::string hexDigest(const std::string& src);
  29. public:
  30. void reset();
  31. void update(const std::string& sp);
  32. // Finalizes the Sha1 operation and fills the buffer with the digest.
  33. // Data is uint8_t digest_[20]
  34. void final(void* digest);
  35. // Hex encoding for result
  36. std::string hexFinal();
  37. private:
  38. void sha1Transform(uint32_t state[5], const uint8_t buffer[64]);
  39. void update(const uint8_t* data, size_t input_len);
  40. void finalInternal();
  41. private:
  42. SHA1(const SHA1&);
  43. const SHA1& operator=(const SHA1&);
  44. struct SHA1_CTX
  45. {
  46. uint32_t state[5];
  47. uint32_t count[2]; // Bit count of input.
  48. uint8_t buffer[64];
  49. };
  50. SHA1_CTX context_;
  51. uint8_t digest_[20];
  52. };
  53. }
  54. }
  55. #endif /* ZL_SHA1_H */