-2

I am currently developing an android application where it can scan qr codes and grab data out of it.

If the qr code is a java coding string, for example : int a; , can i save this string into a method, or even a class and turn it into a java code and run it afterwards?

3
  • 2
    Yes, it is possible, but it sounds like an enormous security headache! Commented Feb 2, 2015 at 8:38
  • If you meant the security of the code, the data in the qr code is gonna be some general data that is supposedly able to be view by anyone so security measurements is not necessarily. Commented Feb 2, 2015 at 8:53
  • 1
    I mean that you have to be incredibly careful executing code from untrusted sources. You have to expect and guard against malicious code in that data, e.g. what happens if I scan a QR code containing the string System.exit(0); or that recursively deletes /. Commented Feb 2, 2015 at 9:04

1 Answer 1

0

See answers to this question for details about how to compile code at runtime.

But I'd strongly advise against it unless you have some means of trusting the code that you are going to compile and execute, or have some means of executing the code in a sandbox/jail, in order that malicious code cannot be injected.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.