Requirements: When we simulate HTTP requests, the request parameters and request content may involve some algorithm content, the algorithm can be found from JavaScript, if we translate the js algorithm into the programming language we use (e.g., Java, C#), it is more difficult, usually the js content is compressed and confused, so if we directly translate js into a class library for us to call, it is very good.
Use JSC to generate the exe program in JavaScript
test1.js code is as follows:
Open the VS 2019 developer command and enter the following:
Try to run the main.exe program, we run the program through the cmd command, double-click directly, and the program will flash by, as follows:
Use JSC to generate a dll library of JavaScript
test.js code is as follows:
The command is as follows:
Create a new .NET 4 console project that references the common.dll class library
Then instantiate the object and call its method. The code is as follows:
As shown below:
You can use the ILSpy tool to view the generated dll source code, as shown in the figure below:
jsc program file path: C:\Windows\Microsoft.NET\Framework\v4.0.30319\jsc.exe
Parameter:
Microsoft (R) JScript Compiler version 14.00.3752 for Microsoft (R) .NET Framework version 4.0.30319 Copyright (C) Microsoft Corporation. All rights reserved.
jsc [options] <源文件> [[options] <源文件>...]
JScript compiler options
- Output File - /out:<file> Specifies the name of the binary output file /t[arget]:exe Create console application (default) /t[arget]: winexe to create a Windows application /t[arget]: library creates a library assembly /platform:<platform> Restricts the platforms on which this code can be run; Must be x86, Itanium, x64, or Any CPU (default platform)
- Input File - /autoref[+|-] Auto-reference assemblies based on imported namespaces and fully qualified names (on by default) /lib:<path> Specifies the additional directory in which you want to search for references /r[eference]:<file list> References metadata from the specified assembly file <file list>: <assembly name>[; <assembly name>...]
- Source - /win32res:<file> Specifies Win32 resource files (.res) /res[ource]:<info> Embed the specified resource <info>: <filename>[,<name>[,public|private]] /linkres[ource]:<info> Links the specified resource to this assembly <info>: <filename>[,<name>[,public|private]]
- Code generation - /debug[+|-] to issue a debug message /fast[+|-] disables language features to make code better generation /warnaserror[+|-] treats the warning as an error /w[arn]:<level> Set the warning level (0-4)
- Miscellaneous - @<filename> For more options, please read the response file /? Show help /help shows help /d[efine]:<symbols> Defines conditional compilation symbols /nologo does not display the compiler copyright mark /print[+|-] provides the print() function
- Advanced - /codepage:<id> Open the source file with the specified code page ID /lcid:<id> Use the specified LCID for messages and default code pages /nostdlib[+|-] does not import the standard library (mscorlib.dll) and changes the autoref default to off /utf8output[+|-] emits compiler output in UTF-8 character encoding /versionsafe[+|-] specifies a default value for members that are not marked as "override" or "hide" (End)
|