Code Monkey home page Code Monkey logo

Comments (2)

gfwilliams avatar gfwilliams commented on September 25, 2024

Normally what we do for that kind of thing is we just allocate a String/flat String containing the info and put it as a child of the variable - you can prefix the name with \xff to hide it from JS. For example this is what we do in Graphics to add a gfx variable with data in it:

>var b = Graphics.createArrayBuffer(8,8,1)
=Graphics: {
  buffer: new ArrayBuffer(8)
 }

so 'gfx' is not visible normally, but if you look inside with 'trace'...

>trace(b)
#10329[r1,l1] Object {
  #10281[r1,l2] Name String [2 blocks] "__proto__"    #19[r4,l0] Object {
      #20[r1,l2] Name String [2 blocks] "constructor"        #17[r3,l0] NativeFunction 0x5e451 (1) {
     .....
   }
  }
  #10332[r1,l2] Name String [2 blocks] "buffer"    #10262[r1,l0] ArrayBuffer (offs 0, len 8)      #10312[r1,l0] String [1 blocks] "\0\0\0\0\0\0\0\0"
  #10268[r1,l2] Name String [1 blocks] "\xFFgfx"    #9718[r1,l0] FlatString [4 blocks] "\0\0\0\b\0\b\0\1\1\0\0\0\0\0\0\0\1 \0\0\0\0\x0F\0\0\0\0\7\0\7\0\xFF\x7F\xFF\x7F\0\x80\0\x80"
}
=undefined
> 

Sure, you could access it from JS if you really tried, but since JS is able to use peek to access any area of memory, anything is ultimately accessible from JS if you try hard enough, so I feel like this is good enough

from espruino.

elima avatar elima commented on September 25, 2024

Thanks for the quick response, @gfwilliams!

Ok, then as I understand it the whole system runs as a single trusted environment; apps can't really keep secrets from other apps.

In this context I agree that the method you describe is enough for hiding data that is not relevant to JS (apart from debugging, maybe). Sounds good.

Closing as feature already exists.

from espruino.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.