Running a javascript file within Java (Android)
<p>I have a website that I want to log into from an android app and in order to submit the POST request with right information, they need some hashed values. The way that the website does it is through a javascript file. I tried tracing through it but I couldn't get the same result as the native website.</p>

<p>So i've decided to download their javascript file and run it within java. </p>

<p>My issue is that I can't figure out how to run specific methods within their file.</p>

<p>Here's my code so far and it's extremely bare bones. </p>

<pre><code>public void hashIt(String valueForMethod1, String valueForMethod2){
    final ScriptEngineManager sem = new ScriptEngineManager();
    ScriptEngine engine = sem.getEngineByName("JavaScript");
    try {
        engine.eval(new java.io.FileReader("res/raw/theirFile.js"));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (ScriptException e) {
        e.printStackTrace();
    }
}
</code></pre>

<p>Any help would be much appreciated :)</p>

<p>Thanks  </p>
