Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <windows.h>
- #include <process.h>
- #include <iostream>
- #include <hmac_sha512.hpp>
- #include <ctime>
- #include <cassert>
- #include <string>
- #include <map>
- #define LUA_LIB
- #define LUA_BUILD_AS_DLL
- extern "C" {
- #include <lauxlib.h>
- #include <lua.h>
- #include <lualib.h>
- #include <luaconf.h>
- #include <compat-5.3.h>
- }
- BOOL APIENTRY Hm512(HMODULE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved
- )
- {
- switch (ul_reason_for_call)
- {
- case DLL_PROCESS_ATTACH:
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
- }
- static int forLua_Hmacsha512(lua_State *L) {
- const std::size_t l = 0;
- std::string secret = luaL_checklstring(L, 1, l);
- std::string params = luaL_checklstring(L, 2, l);
- HMAC_SHA512 hmac_sha512(secret, params);
- std::string d = hmac_sha512.hex_digest();
- // помещаем в стек результат умножения
- lua_pushstring(L, d.c_str());
- return(1); // эта функция возвращает одно значение
- }
- static struct luaL_reg ls_lib[] = {
- { "Hm512", forLua_Hmacsha512 },
- { NULL, NULL }
- };
- extern "C" LUALIB_API int luaopen_Hm512(lua_State *L) {
- luaL_openlib(L, "Hm512", ls_lib, 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement