Java Run System command https://www.cnblogs.com/bencakes/p/6139477.html
Problem, after the tool is large jar package, cannot find the Nodejs file to run where to put the imported jar to put the Nodejs file or put it in an absolute path
Nodejs encryption and then Java runs
PackageCom.tool.java;ImportJava.io.BufferedReader;ImportJava.io.InputStreamReader; Public classSha256 {//sha256 Encryption Public Staticstring encrySha256 (String pass) {string Newpass= ""; if(Pass = =NULL) { returnNewpass; } Try{Process P=NULL; BufferedReader stdout=NULL; String Command= "node./sha256.js" +Pass; P=runtime.getruntime (). exec (command); StdOut=NewBufferedReader (NewInputStreamReader (P.getinputstream ())); String Line; while(line = Stdout.readline ())! =NULL) {Newpass=Line ; } stdout.close (); } Catch(Exception e) {}returnNewpass; }}
' Use strict ' xxxxxxxxxxxxxxxxxxxnodejs encrypted content let Pass;process.argv.foreach (function (val, index) { if (index = = 2 { pass = val; }}); Let Newpass = B (pass) console.log (Newpass)
Java Run Nodejs file