Congrats2u's Recent Forum Activity

  • It works! You have to make a reference in the index.html file, after that you can reference to every javascript file and get those functions to work.... aweseome....

    It was difficould to understand the communication between construct3 and JavaScripts - but after you get it once it is awesome to access your own code.

    Kind of love this engine and Ashley `s perfect support.

  • Javascript librarys with the embeded codec cant be read - i guess - or doesnt seems wo work. We tried to include a cryptojs library with needed functions, but it doesnt work.

  • dop2000

    Thank you very much! With your help i can now understand how it can be done! Very nice!

    Now i have another question, depending on the encryption. The secret encryption needs the HMACSHA256() algorithm, this is part of a library, and not only javascript native programming.

    Is there a possability to include a library into construct3 - For example Crypto.js, it contains hmac encoding functions? Or do you know what would be the best way to achieve hmacsha256 encoding?

    Again thank you so much for your answer! Youre the best!

  • Any Help would be awesome and very important for me..

    Em i right if i include a javascript file into my folder called "files" and in this script is a function like i described above, it should be possible to call the function with some parameters and return a value from it - with the browser.execute("myfunction();") method? Otherwise i dont get it, how to run some JavaScript Code...you can generate a JavaScript file in the files direction, but you cant Access it?

    Set WebToken variable:

    Browser.ExecJS("(function(){ var header = {'alg':'HS256','typ':'JWT'};

    var stringifiedHeader = JSON.stringify(header);

    var encodedHeader = btoa(stringifiedHeader); altert(encodedHeader); })")

    Doesnt work either.

    I checked 100 of differend posts but i dont know why there is no tutorial or example or something, that can provide a guy who never did this before.

    Thanks again for any help!

    I also loaded the JSShell plugin from Rex, but there is no documentation available, with some examples or something. The construct3 files cant be downloaded, because the link isnt actual.

  • gibbon

    Hey! Did you bring this thing to run?

  • Hello there!

    Can someone explain how i could send a variable to a function in my JavaScript, i have added to my Project? There are some calculations i would have to do within this function and then return a string to construct3 again to set it to an variable in my game.

    Can someone tell me how to do that?

    Thank you very much!

    example:

    I have the score and a string (a scecret), i want to send to my crypto.js script. (there is a function inside, which should encrypt those values). Then the function should return a value i would have to return in construct3 and save it, to post this to an url.

    Values in Construct: Score (int), Secret(string).

    Send values to JavaScript: ExecuteJavascirpt(Crypto.js(Score, Secret))

    JavaScript return values to construct: String(XXXX.YYYYY.ZZZZZ) ---- (This function generates a huge string (webtoken), with the encoded values, i would Need in construct to send it to an url)

    Please tell me, if there is something unclear

    In Construct3:

    global variable WebToken:string;

    Set WebToken to (Browser.ExecJS("crypt("&highScore&","&secretVar&");"))

    JavaScript Called Crypto.js, saved in Files folder:

    <script>

    function crypt(score, string){

    var header = {

    "alg": "HS256",

    "typ": "JWT"

    };

    var stringifiedHeader = JSON.stringify(data);

    var encodedHeader = btoa(stringifiedHeader)

    return encodedHeader ; (or even a test retrun "string" doesnt work)

    </script>

    }

    I want to get the generated string from the JavaScript (encryptedString) to set the webtoken varialbe to this value. It does not return anything... is there something wrong? How could i check if the JavaScript function will be triggered?

    __________________________________________________________

    Update:

    Found this: but why is this not working in my case?

  • This is the encoding script (the second one i included into the project)... the question is, if this two scripts are the only one i would need to encode values - but it seems to be so:

    (function () {

    // Shortcuts

    var C = CryptoJS;

    var C_lib = C.lib;

    var WordArray = C_lib.WordArray;

    var C_enc = C.enc;

    /**

    * Base64 encoding strategy.

    */

    var Base64 = C_enc.Base64 = {

    /**

    * Converts a word array to a Base64 string.

    *

    * param {WordArray} wordArray The word array.

    *

    * {string} The Base64 string.

    *

    *

    *

    * ExampLe

    *

    * var base64String = CryptoJS.enc.Base64.stringify(wordArray);

    */

    stringify: function (wordArray) {

    // Shortcuts

    var words = wordArray.words;

    var sigBytes = wordArray.sigBytes;

    var map = this._map;

    // Clamp excess bits

    wordArray.clamp();

    // Convert

    var base64Chars = [];

    for (var i = 0; i < sigBytes; i += 3) {

    var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;

    var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;

    var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;

    var triplet = (byte1 << 16) | (byte2 << 8) | byte3;

    for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {

    base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));

    }

    }

    // Add padding

    var paddingChar = map.charAt(64);

    if (paddingChar) {

    while (base64Chars.length % 4) {

    base64Chars.push(paddingChar);

    }

    }

    return base64Chars.join('');

    },

    /**

    * Converts a Base64 string to a word array.

    *

    * param {string} base64Str The Base64 string.

    *

    * {WordArray} The word array.

    *

    *

    *

    * ExampLe

    *

    * var wordArray = CryptoJS.enc.Base64.parse(base64String);

    */

    parse: function (base64Str) {

    // Shortcuts

    var base64StrLength = base64Str.length;

    var map = this._map;

    var reverseMap = this._reverseMap;

    if (!reverseMap) {

    reverseMap = this._reverseMap = [];

    for (var j = 0; j < map.length; j++) {

    reverseMap[map.charCodeAt(j)] = j;

    }

    }

    // Ignore padding

    var paddingChar = map.charAt(64);

    if (paddingChar) {

    var paddingIndex = base64Str.indexOf(paddingChar);

    if (paddingIndex !== -1) {

    base64StrLength = paddingIndex;

    }

    }

    // Convert

    return parseLoop(base64Str, base64StrLength, reverseMap);

    },

    _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='

    };

    function parseLoop(base64Str, base64StrLength, reverseMap) {

    var words = [];

    var nBytes = 0;

    for (var i = 0; i < base64StrLength; i++) {

    if (i % 4) {

    var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);

    var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);

    words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);

    nBytes++;

    }

    }

    return WordArray.create(words, nBytes);

    }

    }());

  • Hello there,

    i had a similar topic, but i want to ask you now for a more specific area.

    So i have to encode my score value with JSON Web Token library. I want to use the Crypto-js Library, because it uses the HS256 Algorithm i would need. I downloaded it on github : https://github.com/brix/crypto-js

    My question is how to achieve this. If i have a library - can i place it in the root folder of my project, and access this folder with a javascript, i created in construct3?

    When the player wants to submit his score, i request a secret from a URL, which is needet too synchronize the data. This secret has to be encoded by the library function too. So basically there are a score value and the secret value.

    • Now i have the following javascript in my project - this will (should) execute the process:

    var header = {

    "alg": "HS256",

    "typ": "JWT"

    };

    var data = {

    "id": 1337,

    "score": "254"

    };

    var secret = "My very confidential secret!!!";

    function base64url(source) {

    // Encode in classical base64

    encodedSource = CryptoJS.enc.Base64.stringify(source);

    // Remove padding equal characters

    encodedSource = encodedSource.replace(/=+$/, '');

    // Replace characters according to base64url specifications

    encodedSource = encodedSource.replace(/\+/g, '-');

    encodedSource = encodedSource.replace(/\//g, '_');

    return encodedSource;

    }

    var stringifiedHeader = CryptoJS.enc.Utf8.parse(JSON.stringify(header));

    var encodedHeader = base64url(stringifiedHeader);

    var stringifiedData = CryptoJS.enc.Utf8.parse(JSON.stringify(data));

    var encodedData = base64url(stringifiedData);

    var signature = encodedHeader + "." + encodedData;

    signature = CryptoJS.HmacSHA256(signature, secret);

    signature = base64url(signature);

    From the Library i took the enc-base64 script, i thought it would be the script which is needed to encode the values. The question is how to combine two extern javascripts with each other. Or if basically the complete library is still needed to access...

    • So the score and the secret are the only variables i have in construct, and i would have to complete in this javascript (Thats the first question, how can i use the command to set those values into the javascript).

    -The second question: The Javascript calls the CryptoJS.enc.Utf8 library, how can i setup the connection to a library, which isnt included in the project? Can i access it, when it is in the project folder? ( or in the root of the project)?

    And i would have to receive the encrypted value/string, which would look like this:

    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTMzNywic2NvcmUiOiIyNTQifQ.xSv1wylmcO5VW5_bbWxrTmvnX9IaTbWWQbDNxjyuSL4

    (Header:Payload:Security)

    It would be so important, if someone could tell me how to achieve this... or if its possible to do that with construct3 - its my first time to using a library, or setup a connection between c3 and javascripts and libraries, which are not included in construct3.

    Thank you so much for your help!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hello there!

    At first:

    Ive made a project which runs on every browser. I have windows 10 with edge where you can use ie 11 and emulate all other versions of ie. If i run it on my computer (and also on others in the office) it works.

    But our customer told us, that it doesnt work on their computer with ie11 (see specs below). He has only a black screen - no loading bar etc.

    And now the question:

    If the game runs on every browser (firefox, chrome, safari, edge and ie11) on all my machines i could test (the project is uploadet to a server, how it would be finally uploaded), what could be the general problem on his browser? I know this question is very general...but maybe someone knows what could be the problem, because i cant say.

    I think this could be a problem which has nothing to do with the browser. He told us he could load all other games but not this one.

    • Could it be the server we uploaded the project?
    • Or his hardware (the other games are similar, depending on the basic needed hardware specifications so i

    think this isnt the problem)

    • Could they have a browser setting which blocks the game?
    • Firewall? - but they dont get a message or a notification...

    Customer browser specs:

    Version 11.0.9600.18837

    Update-version: 11.0.48

    I know its difficould to say what it could be, without no application - but i think its something "out of the box" - like i said on my test machines the game runs perfect in all browsers...

    Maybe i have luck with this thread and someone will give me the final golden hint, i could ask them to take a look for.

  • Yea thats sad...the plugins where good.

  • dop2000

    okay - have to take a look how to do this - did you got some experience with that?

  • dop2000

    Thank you for the information - the plugin isn´t available for construct3 i guess. Do you know alternatives?

    Documentation Link:

    https://jwt.io/

    But the basic question i have is how to use this (i think there are several pages like i included above) method with construct3.

    It should be possible with get and post functions but to use this encoding it shouldn´t be a post command to an extern library, because this could be manipulated too (to avoid this is the basic function of this token), so i guess i would have to have a kind of library in my root folder and use a "encode my variable and send it to url" function...

    but iam absolutly not sure with my intention. Maybe i get something wrong in understanding this thing...

    Thats why iam asking for helping people like you <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    Note: I saw, that the question is how to do this in construct2 but i made the project with construct3

Congrats2u's avatar

Congrats2u

Member since 3 Jun, 2016

None one is following Congrats2u yet!

Trophy Case

  • 8-Year Club
  • Forum Contributor Made 100 posts in the forums
  • RTFM Read the fabulous manual
  • Email Verified

Progress

11/44
How to earn trophies