欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

ASP页面随机添加字符实现防复制的代码

程序员文章站 2022-05-18 11:37:32
<%         '作用:文字防复制乱码 函数   ...
<%
        '作用:文字防复制乱码 函数
        'date:2006-3-6
        '作者:blue2004
        '参数str 为原文,str1作者也是你自己,reslut产生乱码的种子
        function readtocode(str,str1,result)
                dim name
                dim i,j,k
                if isnull(str) then
                        readtocode=""
                        exit function
                end if
                randomize 
                k=instr(str,"</p>")
                do while k>0
                        result=""
                        for i=0 to 19
                                j=int(128 * rnd)+1
                                if j=60 or j=62 then
                                        j=j+1
                                end if
                                result =result&chr(j) ' 产生随机数。
                        next 
                        result="<span style='display: none'>"&result&"</span>"
                        str=replace(str,"</p>",result&"<'/p>",1,1)
                        k=instr(str,"</p>")
                loop
                str=replace(str,"<'/p>","</p>")

                k=instr(str,"<br>")
                do while k>0
                        result=""
                        for i=0 to 19
                                j=int(128 * rnd)+1
                                if j=60 or j=62 then
                                        j=j+1
                                end if
                                result =result&chr(j) ' 产生随机数。
                        next 
                        result="<span style='display: none'>"&result&"</span>"
                        str=replace(str,"<br>",result&"<'br>",1,1)
                        k=instr(str,"<br>")
                loop
                str=replace(str,"<'br>","<br>")
                readtocode=str&"<div align=right style='color=gray'>[版权归原作者及"&str1&"共同拥有,转载请注明出处]</div>"
        end function


dim a 
a="嘎嘎,一篇<br>不错的好<p>文章哦</p><br><p>我艹,,让你偷。。木 jj的家伙,嬲。。</p>"


'only for test
response.write (a)

dim b
'为配合转换,字符串a的大小都替换成小写
b=readtocode(lcase(a),"blue2004","www.xxx.com")

'output
response.write b
%>