• As @DrAzzy says - because Espruino executes from source code, there are limits to how much you can 'hide' your code. However you can 'minify' your code, which (especially if you minify it yourself with more advanced optimisations turned on) will obfuscate it so much that nobody will be able to do anything useful with it.

    Have a quick google - there are a few options as obviously this comes up quite a lot with all the websites that use JavaScript and want to protect their IP.

    If you want to load code from the SD card (I guess you want to do this to allow quick upgrades?) it's as simple as writing a really simple bootloader and saving that to Espruino:

    function onInit() {
      eval(require('fs').readFile("boot.js"));­
    }
    

    If you want to make it more difficult for users to copy the code to another Espruino, you could look at encrypting the file somehow such that it can be decrypted with Espruino's unique ID (which you can get from process.env).

  • Hi @Gordon,

    function onInit() {
      exec(require('fs').readFile("boot.js"));­
    }
    

    i can't find any documentation about "exec". I tried it with my pico, but i just get

    Uncaught ReferenceError: "exec" is not defined at line 3 col 3
    exec();

    I would like to execute some code, that is stored on an connected sd card.
    What is missing? Could you help me with that?

    Thank you :)

About

Avatar for coffeeDrink @coffeeDrink started