Hey!

So you want to decrypt code, and then run it? Now, thats a bit different! ^^
I would suggest using the v8::Script interface for one, but you may want to 
pass "this" to the native function anyway. The context the C++ code is ran is 
essentially the same as if it were running as a real nodejs function. The 
difference is jsut the "language" and typing. v8::Script therefore acts as if 
it was eval(), but requires a script parameter. I just looked into the stuff 
again, and here is what I belive you can do.

        char* script = "...";
        v8::Script sc = v8::Script::Compile(script, "internal.js");
        sc->Run();

This way, you keep the stuff inside your binary.  The Compile function 
will...compile the code. I am not certain how to pass the real context - but it 
should be automaticaly set. Look at the link I sent, so you can get a better 
udnerstanding. There is also a small file called shell.cc, which does similar 
things.

Wish you luk with that, thats not an easy task! :)
Am Fr. Apr. 11 2014 09:28:01 schrieb samonzeweb:

> Thanks for your reply, and code.
> 
> > Well, what are you expecting in an empty this object? XD You have nothing 
> > assigned to it! Therefore, it will stay empty.
> 
> I does a mistake about scope (with"dummy"), but I expected to see Node 
> "require". Running code with Node allow you to call "require" from 
> everywhere. But with my C++ code I can't call JS code with "require". I want 
> to understand why I have such a difference between JS code run "directly" and 
> JS code called from C++. Of course I didn't understand something but I didn't 
> see what.
> 
> I'll have to admit my first post was not clear enough. Perhaps could have I 
> asked "Why I didn't see Node stuff, can't call Node sufff from my JS code 
> called from C++ like I does" Sorry. I'll check you sample code, and take more 
> time in V8 documentation.
> 
> > [...] run arbitary JS code. But to be honest, I would not do this. Consider 
> > the binary functions as access into the low level, and try to write as much 
> > as you can via JavaScript.
> 
> YES, I agree with that. C++ for low level, and don't doing a awful spaghetti 
> code between C++ and JS. But in a particular case I search a way to run 
> hidden JS code. Just a small part of code nobody has to see or touch after 
> deployment on customer infrastructure. The idea is to load encrypted JS code, 
> decrypt it from C++, and run it when needed. But I need Node functionality 
> (like "require"), not just V8.
> 
> I know there are others problems than just running JS code from C++, i.e. 
> because with JS it's easy to display function code. But one problem at a 
> time, and first I check what is really possible or not.
> 
> Sam.
> 
> Le jeudi 10 avril 2014 19:22:44 UTC+2, Kevin Ingwersen a écrit :
> Well, what are you expecting in an empty this object? XD You have nothing 
> assigned to it! Therefore, it will stay empty. Again, check the v8 docs and 
> look for v8::Script, which esentialy is what oyu want; it lets you run 
> arbitary JS code. But to be honest, I would not do this. Consider the binary 
> functions as access into the low level, and try to write as much as you can 
> via JavaScript. If you wish to use data from an existing object, you could 
> end up writing something like this?
> 
>  
> [....]


-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to