You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • For the initial question - no, you can't pipe to eval I'm afraid. Espruino needs to have the whole string of code in memory to execute it.

    You may find the 'rollups' are a bit more efficient? For instance: http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/aes.js

    However having looked at it, I think that AES implementation is too big to go in Espruino - not so much the code, but it allocates some arrays, and I think those fill up the available memory. With a bit of tweaking and changing to Int32Arrays you might be able to fit it in though.

    You could always use MD5, which seems to be a bit more efficient: http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/md5.js

    You can actually copy the contents of the rollup, paste it into the Web IDE and do:

    function unescape(a){return a;} // this is needed by the MD5 lib...
    function encodeURIComponent(a){return a;} // this is needed by the MD5 lib...
    CryptoJS.MD5("Hello").toString()
    

    But having said that, the answer gained from the MD5 library on Espruino doesn't match what I get from a desktop JS implementation. I'll try and find out why, but I'm not sure when I'll have time, so if anyone is able to track down which operation in Espruino isn't working as expected it'd be hugely helpful!

About

Avatar for Gordon @Gordon started