Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <windows.h>
  3. #include <process.h>
  4. #include <iostream>
  5. #include <hmac_sha512.hpp>
  6. #include <ctime>
  7. #include <cassert>
  8. #include <string>
  9. #include <map>
  10.  
  11.  
  12. #define LUA_LIB
  13. #define LUA_BUILD_AS_DLL
  14.  
  15.  
  16. extern "C" {
  17. #include <lauxlib.h>
  18. #include <lua.h>
  19. #include <lualib.h>
  20. #include <luaconf.h>
  21. #include <compat-5.3.h>
  22. }
  23.  
  24.  
  25. BOOL APIENTRY Hm512(HMODULE hModule,
  26. DWORD ul_reason_for_call,
  27. LPVOID lpReserved
  28. )
  29. {
  30. switch (ul_reason_for_call)
  31. {
  32. case DLL_PROCESS_ATTACH:
  33. case DLL_THREAD_ATTACH:
  34. case DLL_THREAD_DETACH:
  35. case DLL_PROCESS_DETACH:
  36. break;
  37. }
  38. return TRUE;
  39. }
  40.  
  41.  
  42. static int forLua_Hmacsha512(lua_State *L) {
  43.  
  44. const std::size_t l = 0;
  45. std::string secret = luaL_checklstring(L, 1, l);
  46. std::string params = luaL_checklstring(L, 2, l);
  47.  
  48. HMAC_SHA512 hmac_sha512(secret, params);
  49. std::string d = hmac_sha512.hex_digest();
  50.  
  51. // помещаем в стек результат умножения
  52. lua_pushstring(L, d.c_str());
  53.  
  54. return(1); // эта функция возвращает одно значение
  55. }
  56.  
  57.  
  58. static struct luaL_reg ls_lib[] = {
  59. { "Hm512", forLua_Hmacsha512 },
  60. { NULL, NULL }
  61. };
  62.  
  63. extern "C" LUALIB_API int luaopen_Hm512(lua_State *L) {
  64. luaL_openlib(L, "Hm512", ls_lib, 0);
  65. return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement