首页 | DV动态 | 数码产品 | 视频采编 | 网站建设 |
【收藏DV】
  最近3月排行
·赤马劫
·985、211、双一流
·许小年:碎片化信息让人变得无知,要少看手机多读书
·上了大学也没体面工作,我们是否还要上大学- 附一组数据
·许小年:浅析日本失去的30年——兼评“资产负债表衰退”
·高中英语-单词表
·常用网管软件下载,持续更新中...
Script Encoder 语法
2006/9/5 9:44:28
 

Script Encoder Syntax

SCRENC [/s] [/f] [/xl] [/l defLanguage ] [/e defExtension] inputfile outputfile

Argument
Description

/s
Optional. Switch that specifies that the script encoder is to work silently; that is, produce no screen output. If omitted, the default is to provide verbose output.

/f
Optional. Specifies that the input file is to be overwritten by the output file. Note that this option destroys your original input source file. If omitted, the output file is not overwritten.

/xl
Optional. Specifies that the <@language> directive is not added at the top of .asp files. If omitted, the <@language> directive is added for all .asp files.

/l defLanguage
Optional. Specifies the default scripting language (JScript or VBScript) to use during encoding. Script blocks within the file being encoded that do not contain a language attribute are assumed to be of this specified language. If omitted, JScript is the default language for HTML pages and scriptlets, while VBScript is the default for ASP. For plain text files, the file extension (either .js or .vbs) determines the default scripting language.

/e defExtension
Optional. Associates the input file with a specific file type. Use this switch when the input file's extension doesn't make the file type obvious; that is, when the input file extension is not one of the recognized extensions, but the file content does fall into one of the recognized types. There is no default for this option. If a file with an unrecognized extension is encountered and this option is not specified, the script encoder fails for that unrecognized file. Recognized file extensions are .asa, .asp, .cdx, .htm, .html, .js, .sct, and .vbs.

inputfile
Required. The name of the input file to be encoded, including any necessary path information relative to the current directory.

outputfile
Required. The name of the output file to be produced, including any necessary path information relative to the current directory.





--------------------------------------------------------------------------------

Figure 3 Encoding a Page



Public Sub EncodePage()
     ' Sample encoder
     ' Andrew Clinick Jan 1999
     ' Obviously this code could do with some error trapping etc
     ' but it should give you the basics to get started
    
    
     Dim strHTML As String
     ' Get the Frontpage document
     Dim mydoc As FPHTMLDocument
     ' Create a new instance of the scripting.encoder object
     Dim myEncoder As New Scripting.Encoder
     ' Get the current active document
     Set mydoc = ActiveDocument
     ' Get the HTML for the active document
     strHTML = mydoc.DocumentHTML
     ' Call the encodescriptfile method with the HTML
     strHTML = myEncoder.EncodeScriptFile(".htm", strHTML, 0, "")
     ' Set the documentHTML to be the return HTML with encoded script
     mydoc.DocumentHTML = strHTML
     ' We're done!
End Sub  
==============================================================


<font color=Red>Microsoft 脚本编码器Script Encoder介绍</font>

脚本编码器是一种简单的命令行工具,它使脚本设计者可以对最终的脚本进行编码,从而使 Web 主机和 Web 客户不能查看或修改它们的源代码。注意,这种编码只能防止别人在无意中查看到您的代码,并不能防止蓄意黑客查看您的编码内容及其方法。
Web 设计者在 Web 页和服务器的 Active Sever Pages (.ASP)上编写脚本,足以在网页上添加您能想象到的所有功能。此外,Windows® Scripting Host(WSH) 和许多其他的应用程序也进行脚本编写,并取得了同样好的效果。

到目前为止,使用脚本的一个缺点是它既不能保护脚本内的知识产权,又不能保证用户所看到的就是您所创造的成果。聪明的运算法则和精心设计的脚本总是能完全被看见,因为它们是作为普通文字储存的。因此,每一级的脚本用户都能看到脚本设计者的原始编码,并能取出、修改它们,从而据为己有。显然,如果您正想在某一竞争激烈的领域占上风,这对您是非常不利的。

随着脚本小程序的引进,保护源代码变得更加重要。脚本设计者都希望使用这一简单的部件层次结构,但却并不一定想与他人共享自己的源代码。只要脚本经编码后,改变结果文件的任一部分都会使得脚本无法执行,这样,就保证了您编码脚本的绝对完整。

本篇有关脚本编码器的文档包含如下几个主题:

使用脚本编码器

脚本编码器语法

编码示例  
使用脚本编码器


脚本编码器只对脚本代码进行编码,文件的其他内容不动且以普通文本形式显示。要使用脚本编码器,以通常方法对文本进行开发和调试,然后使用该实用程序对最终的脚本进行编码。 脚本编码器在源代码中使用标记来标识编码开始的位置。
对于 Visual Basic® Scripting Edition (VBScript),如下示例显示了如何使用编码标记来显示普通文本的版权信息:


<SCRIPT LANGUAGE="VBScript">
'Copyright© 1998. XYZ Productions. All rights reserved.
'**开始编码**
' 这里放您的代码.
</SCRIPT>

在 JScript® 中,编码标记如下:

<SCRIPT LANGUAGE="JScript">
//Copyright© 1998. ZYX Productions. All rights reserved.
//**开始编码**
// 这里放您的代码.
</SCRIPT>

当脚本编码器被调用时,在开始标记前,脚本块内的内容保持不变,而其他内容被编码。因此,如果开始标记被省略,则脚本编码块内的所有内容均被编码,但如果开始标记在脚本编码块的最后,则不对任何内容进行编码。
在编码发生后。您应该知道 <SCRIPT> 标记中的语言指示符已改变。对于 VBScript,新的指示符如下:

<SCRIPT LANGUAGE="VBScript.Encode">

对于 JScript (或 JavaScript),新的指示符如下:
<SCRIPT LANGUAGE="JScript.Encode">

脚本编码器在如下所示的 MS-DOS 命令行或“运行”对话框中被调用:
SRCENC [switches] inputfile outputfile

关于该实用程序的语法在脚本编码器语法中解释。  

脚本编码器语法


描述
对脚本编写源代码进行编码,使其不会轻易地被用户查看或修改。

语法
SCRENC [/s] [/f] [/xl] [/l defLanguage ] [/e defExtension] inputfile outputfile

脚本编码器语法的组成部分如下:

部分 描述
/s 可选的。 开关,它指定脚本编码器的工作状态是静态的,即产生无屏幕输出。如省略,缺省为提供冗余输出。
/f 可选的。指定输入文件将被输出文件覆盖。 注意,该选项会破坏您原来的输入源代码。如省略,输出文件不会被覆盖。

/xl 可选的。指定不把 @language 伪指令添加到 .ASP 文件顶部。如省略,@language 指令添加到所有的 .ASP 文件中。
/l defLanguage 可选的。指定在编码过程中使用的缺省脚本编写语言 (JScript® 或 VBScript)。被编码文件中的脚本块如不包含语言属性,即被认为是由指定语言写成。 如省略,JScript 是 HTML 页和脚本小程序的缺省语言,VBScript 是动态网页的缺省语言。对于普通文本文件,由文件扩展名 ( .js 或 .vbs)决定缺省脚本编写语言。
/e defExtension 可选的。把输入文件与一个特定的文件类型相关联。当输入文件的扩展名不能明显显示出文件的类型时,即,当输入文件扩展名不是可识别的扩展名,但文件内容又可以归为可识别的类型时,使用该开关。该选项无缺省值。如果遇到一个带不可识别的扩展名的文件,且该选项未被指定,则脚本编码器不能处理该不可识别的文件。可识别的文件扩展名有 asa、asp、cdx、htm、html、js、sct和 vbs。
inputfile 必需的。要被编码的文件名称,包括相对于当前目录的任何需要的路径信息。
outputfile 必需的。要生成的输出文件的名称,包括相对于当前目录的任何需要的路径信息。


说明
如下是脚本编写器能处理的四种文件:
ASP。该格式由一个文本动态网页组成,此网页在 <SCRIPT> ... </SCRIPT> 标记或 <% ... %> 标记内包含有效的 HTML 和内嵌脚本块。使用该格式的应用程序包括 Microsoft® Internet Information Services (IIS)。识别文件扩展名有 .asp、.asa 和 .cdx。
HTML。该格式由一个包含有效的 HTML 和内嵌脚本块的文本文件组成。使用该脚本格式编写的应用程序包括 Microsoft FrontPage®, Microsoft® Visual InterDev™ 和所有虚拟的 Web 设计器及浏览器。识别文件扩展名有 .htm 和 .html。
普通文本。该格式由只包含脚本而无两端标记的文本文件组成。使用该脚本格式编写的应用程序包括 Windows® Scripting Host (WSH) 和 Microsoft® Outlook®。 识别文件扩展名有 .js 和 .vbs,经编码后,分别变为 .jse 和 .vbe。
脚本小程序。该格式由一个在 <SCRIPT> ... </SCRIPT> 标记中包含有效脚本小程序的文本文件组成。识别文件扩展名有 .sct 和 .wsh。
示例
如下是使用脚本编码器的一个例子以及对其结果的简单解释:
对输入文件 test.html 进行编码,生成输出文件 encode.html,使用:

screnc test.html encode.html

对输入文件 test.htm 进行编码,并用编码后的输出文件覆盖输入文件,使用:
screnc /f test.htm

对当前目录中的所有 .ASP 文件进行编码,并把编码后的输出文件放在c:\temp中,使用:
screnc *.asp c:\temp

对当前目录中的所有 .ASP 文件进行编码,并把编码后的输出文件放在c:\temp中,使用:
screnc /e asp *.* c:\temp

对输入文件 test.htm 进行编码,并生成输出文件 encode.htm,确保没有指定语言属性的脚本块使用 VBScript,使用:
screnc /l vbscript test.htm encode.htm

对当前目录中的所有脚本小程序文件进行编码,并不经信息显示就用编码后的文件覆盖这些文件,使用:
screnc /s /f *.sct  

编码示例


如下是一个包含需要保护的 JScript 代码的简短示例:
<HTML>
<HEAD>
<TITLE>脚本编码器示例页</TITLE>
<SCRIPT LANGUAGE="JScript">
<!--//
//Copyright© 1998 Microsoft Corporation. All Rights Reserved.
//**开始编码**
function verifyCorrectBrowser(){
if(navigator.appName == "Microsoft Internet Explorer")
    if (navigator.appVersion.indexOf ("5.") >= 0)
     return(true);
    else
     return(false);
}
function getAppropriatePage(){
var str1 = "Had this been an actual Web site, a page compatible with ";
var str2 = "browsers other than ";
var str3 = "Microsoft Internet Explorer 5.0 ";
var str4 = "would have been loaded.";
if (verifyCorrectBrowser())
    document.write(str1 + str3 + str4);
else
    document.write(str1 + str2 + str3 + str4);
}
//-->
</SCRIPT>
</HEAD>
<BODY onload="getAppropriatePage()">
</BODY>
</HTML>

该页在经脚本编码器运行后如下所示:
<HTML>
<HEAD>
<TITLE>脚本编码器示例页</TITLE>
<SCRIPT LANGUAGE="JScript.Encode">
<!--//
//Copyright© 1998 Microsoft Corporation. All Rights Reserved.
//**开始编码**#@~^QwIAAA==@#@&0;  mDkW  P7nDb0zZKD.n1YAMGhk+Dvb`@#@&P,kW`UC7kLlDGDcl22gl:n~{'~Jtr1DGkW6YP&xDnD  +OPA62sKD+ME#@#@&P,~~k6PvxC\rLmYGDcCwa.n.kkWU bx+X66Pcr*cJ#,@*{~!*P~P,P~.YEMU`DDEbIP,P,+s/n@#@&P~P,~PM+O;Mx`WC^/n#pN6EU1YbWx,oObaw.WaDrCD+nmL+v#  @#@&~P7lMPdY.q,'~J_CN,Y4rkP4nn  PCx,C1Y;mV,+(PkrY~~l,wCLPmKhwmYk(snPSkDt~JI@#@&P~\m.PkY.+,'PE8MWA/.kPGDtDPDtmUPri@#@&,P-CMP/D.&,'Pr\rmMWkWWY~(  YnD  nY,2a2^WDn.,* !,Ep@#@&,P7lD,/D.c,'~JSW;s9Ptm-+,4+U~VKl9+[REI,Pr0,c\DrWHZW..mOAMGS/nM`*#@#@&P,~P9W^Es+UOchDbO+v/YMq~_,/DDfPQ~kY.c*IP,+sd@#@&~~,P[W1;s+UDRSDkD+vdYMF~_,/O.yP_,dYM&P3~dYMc*iNz&R @*^#~@
//-->
</SCRIPT>
</HEAD>
<BODY onload="getAppropriatePage()">
</BODY>
</HTML>

要点 :经过编码后,如果您改动编码后的文本,哪怕只改动一个字。脚本的完整性就会丢失,从而不能再使用。 (DVOL本文转自:中国DV传媒 http://www.dvol.cn)

欢迎关注微信公众账号:手机烟台(mYantai)

 

  上一篇:ASP中正则表达式的应用
  下一篇:Mysql日常备份和增量备份脚本(Linux)
      更多...
::打印本页 ::      ::关闭窗口::


版权所有© 数码在线网站 DV OnLine©  鲁ICP备12016322号-1