[Solved]Encode string with base64

0 favourites
From the Asset Store
A collection of a mix of percussion and orchestral string loops, including 20 musical sketches.
  • Hello everybody,

    I want to encode a string using base64

    like base64_encode() in php.

    But after few days of searhing, I don't found the solution. <img src="smileys/smiley19.gif" border="0" align="middle" />

    Thanx in advance for your help <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Up please, i need it :/

    P.S: Please don't tell me to use Ajax GET/POST to encode my string using PHP.

    I very need to encode directly in Construct 2.

  • With the Browser object and the javascript btoa() function:

    base64encode.capx (r140)

    <img src="https://dl.dropboxusercontent.com/u/8367729/construct/pics/base64encode_1.PNG" border="0">

    <img src="https://dl.dropboxusercontent.com/u/8367729/construct/pics/base64encode_2.PNG" border="0">

    I'm pretty sure there's a 3rd party plugin that does it as well.

  • Thanx man :D

  • Does this work from an iPhone?

    this is what i get

    TypeError: 'undefined' is not a function (evaluating 'window.btoa(

    ypeError: 'undefined' is not a function (evaluating 'btoa(

    where is the btoa object? how do i access this from? Don't understand why it works in C2 and chrome but iPhone spits out the i don't know this object error

  • darkstar It depends on the browser. Are you using CocoonJS? It might not be supported...

  • Wrote a plugin to extend the functionality to a expression that could be evaluated and return.

    This ended up being the least painful way to do this. I was using Cocoon, but have just recoded everything around Ejecta.

  • Up please, i need it :/

    P.S: Please don't tell me to use Ajax GET/POST to encode my string using PHP.

    I very need to encode directly in Construct 2.

    Hi would you upload the solution again? the dropbox link is not working anymore.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • With the Browser object and the javascript btoa() function:

    base64encode.capx (r140)

    <img src="https://dl.dropboxusercontent.com/u/8367729/construct/pics/base64encode_1.PNG" border="0">

    <img src="https://dl.dropboxusercontent.com/u/8367729/construct/pics/base64encode_2.PNG" border="0">

    I'm pretty sure there's a 3rd party plugin that does it as well.

    Hi would you upload the solution again? the dropbox link is not working anymore.

  • Text variable base64text
    
    Set base64text to Browser.ExecJS("btoa('some text to encode')")
    
  • > Text variable base64text
    
    Set base64text to Browser.ExecJS("btoa('some text to encode')")
    

    Great! Thank you buddy!

  • > Text variable base64text
    
    Set base64text to Browser.ExecJS("btoa('some text to encode')")
    

    Do you think the JS will be blocked on some browser? Like Safari on iOS?

  • It can be. But then your game will simply not start, so you don't have to worry about this :)

  • It can be. But then your game will simply not start, so you don't have to worry about this :)

    Aha, so it mean if the JS is blocked by the browser, the whole game made by Construct2 can not work on it?

  • I just tried it on my old iPhone (iOS 12.0.1) and it worked fine.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)