codec.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "sol/sol.hpp"
  3. #include "basemodule.h"
  4. namespace module
  5. {
  6. /// <summary>
  7. /// 编解码
  8. /// </summary>
  9. class codec{
  10. public:
  11. /// <summary>
  12. /// URL解码
  13. /// </summary>
  14. static std::string url_de(const std::string& value);
  15. /// <summary>
  16. /// URL编码
  17. /// </summary>
  18. static std::string url_en(const std::string& value);
  19. /// <summary>
  20. /// GBK转UTF8
  21. /// </summary>
  22. /// <returns></returns>
  23. static std::string to_utf8(const std::string& value);
  24. static std::string to_gbk(const std::string& value);
  25. /// <summary>
  26. /// MD5校验
  27. /// </summary>
  28. /// <param name="value"></param>
  29. /// <returns></returns>
  30. static std::string md5(const std::string& value);
  31. static std::string sha1(const std::string_view& value);
  32. static std::string sha256(const std::string_view& value);
  33. static std::string hmac_sha256(const std::string_view& key,const std::string_view& value);
  34. static std::string aes_encode(const std::string_view& value, const std::string_view& key, const std::string& variant,const std::string& mode);
  35. static std::string aes_decode(const std::string_view& value,const std::string_view& key, , const std::string& variant, const std::string& mode);
  36. static void regist(sol::state* lua);
  37. };
  38. }