Josh Posted December 2, 2016 Author Share Posted December 2, 2016 And I've added functions that make it so you never have to touch the REST stuff: static bool SetKeys(const std::string& gamekey, const std::string& secretkey);//lua static bool SendDesignEvent(const std::string& eventid);//lua static bool SendDesignEvent(const std::string& eventid, const float value);//lua static bool SendErrorEvent(const int severity, const std::string& message);//lua static bool SendProgressEvent(const int status, const std::string& levelname);//lua static bool SendProgressEvent(const int status, const std::string& levelname, const int score);//lua static bool SendProgressEvent(const int status, const std::string& levelname, const int score, const int attempt_num);//lua static bool SendResourceEvent(const int flowType, const std::string& currency, const std::string& itemType, const std::string itemid, const float amount);//lua Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
martyj Posted December 3, 2016 Share Posted December 3, 2016 For the life of me I cannot reproduce the hmac hash. Using the key from the python file and the JSON from my sample, I get the following: import hmac import hashlib key = "16813a12f718bc5c620f56944e1abc3ea13ccbac" data = "{\"platform\":\"Windows\", \"os_version\":\"10\", \"sdk_version\":\"api v2\"}"; hash = hmac.new(key, data, digestmod=hashlib.sha256) hash.hexdigest() Produces the following HEX string a39a45d2ac53e7c4d9e3b978267a6442cad0c396a52500e6c3be9e5bb1e6edbb Using the library I posted earlier I get a completely different result. Using the following code which uses OpenSSL's version #include <string.h> #include <stdio.h> #include <openssl/hmac.h> #include <openssl/evp.h> void hmac(unsigned char* key, unsigned char* message, int keylen, int messagelen, unsigned char* out) { HMAC_CTX ctx; HMAC_CTX_init(&ctx); unsigned int len = 32; unsigned char* data[32]; // Using sha1 hash engine here. // You may use other hash engines. e.g EVP_md5(), EVP_sha224, EVP_sha512, etc HMAC_Init_ex(&ctx, key, 20, EVP_sha256(), NULL); HMAC_Update(&ctx, message, messagelen); HMAC_Final(&ctx, out, &len); HMAC_CTX_cleanup(&ctx); memcpy(out, data, len); memset(out+len, 0, 32-len); for(int i = 0; i < len; i++) { printf("%02x", out[i]); } printf("\n"); } int main(int argc, const char *const *argv) { unsigned char buff[32]; const char* message = "{\"platform\":\"Windows\", \"os_version\":\"10\", \"sdk_version\":\"api v2\"}"; const char* key = "16813a12f718bc5c620f56944e1abc3ea13ccbac"; hmac((unsigned char*)key, (unsigned char*)message, sizeof(key), sizeof(message), buff); } I get the following printed. 0000000000000000b076bf49007f0000d859c149007f00008707400000000000 This sample code seems to work well. The problem is it is only windows. http://stackoverflow.com/questions/22147895/is-it-possible-to-do-a-hmac-with-wincrypt 2 Quote Link to comment Share on other sites More sharing options...
martyj Posted December 6, 2016 Share Posted December 6, 2016 Success! Did some digging around in my test code. Apparently sizeof(char*) doesn't return the size of the static array, but just the size of a charater. Thanks G++. http://martyj.net/curl.zip I can't find libcurl-dev on windows for the life of me, so I had to use Linux. As I am working off of a server, I don't have Leadwerks setup so I cannot implement it in your class. Sorry about the indentation as well. I was using nano to modify the files. But this should help hopefully. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted December 6, 2016 Author Share Posted December 6, 2016 Sweet! This is going to rock. Thanks for your help, this is definitely way outside my area of specialty. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted December 11, 2016 Author Share Posted December 11, 2016 It's working. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
martyj Posted December 11, 2016 Share Posted December 11, 2016 I am really excited for this functionality. I'm delaying a demo version update for this content as well. If there's anything more I can do to help, let me know! Quote Link to comment Share on other sites More sharing options...
Josh Posted December 11, 2016 Author Share Posted December 11, 2016 I think I'm good. Thanks a lot for your help, this was really tricky. Here's the final API: static bool Enable();//lua static void Disable();//lua static void SetKeys(const std::string& gamekey, const std::string& secretkey);//lua static bool SendGenericEvent(const std::string& eventid);//lua static bool SendGenericEvent(const std::string& eventid, const float value);//lua static bool SendErrorEvent(const std::string& severity, const std::string& message);//lua static bool SendProgressEvent(const std::string& status, const std::string& levelname);//lua static bool SendProgressEvent(const std::string& status, const std::string& levelname, const int score);//lua static bool SendProgressEvent(const std::string& status, const std::string& levelname, const int score, const int attempt_num);//lua static bool SendResourceEvent(const std::string& flowType, const std::string& currency, const std::string& itemType, const std::string& itemid, const float amount);//lua static bool SendBusinessEvent(const std::string& itemType, const std::string& itemid, const int amount, const std::string& currency, const uint64_t transaction_num, const std::string& cart_type = "", const std::string& receipt_info="");//lua 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 12, 2016 Share Posted December 12, 2016 This is awesome. I might have missed it, but will this be released before the end of the tournament. Quote Link to comment Share on other sites More sharing options...
Josh Posted December 13, 2016 Author Share Posted December 13, 2016 This is awesome. I might have missed it, but will this be released before the end of the tournament. Will be out next week. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.