• 网页内容加密


    1、防止保存<NOSCRIPT><IFRAME SRC=*.html></IFRAME></NOSCRIPT>

    2、防止拷贝<body  ondragstart="return false" onselectstart="return false">

    3、实现上两条好办,可是要查看源码,一切就都摆给人家了。

    参考网上实现方法,也就是密码表和移位运算,实现了对网页文字加密。

    加密函数文件

    <%

    Public Const sDefaultWHEEL1 = "ABCDEFGHIJKLMNOPQRSTVUWXYZ_1234567890qwertyuiopasd!@#$%^&*(),. ~`-=\?/’""fghjklzxcvbnm<>;"
    Public Const sDefaultWHEEL2 = "IWEHJKTLZVOPFG_1234567890qwerBNMQRYUASDXCfghjklzxc ~`-=\?/’""!@#$%^&*(),.vbnm<>;tyuiopasd"

    Function Encrypt_PRO(sINPUT , sPASSWORD )
    Dim sWHEEL1, sWHEEL2
    Dim k, c, i
    Dim sRESULT
    sWHEEL1 = sDefaultWHEEL1: sWHEEL2 = sDefaultWHEEL2
    'ScrambleWheels sWHEEL1, sWHEEL2, sPASSWORD
    sRESULT = ""
    For i = 1 To Len(sINPUT)
    c = Mid(sINPUT, i, 1) '逐个取输入字符
    k = InStr(1, sWHEEL1, c) ' 返回c在sDefaultWHEEL1的位置
    If k > 0 Then
    sRESULT = sRESULT & Mid(sWHEEL2, k, 1)  '用sDefaultWHEEL2同等位置的字符代替sDefaultWHEEL1
    Else
    sRESULT = sRESULT & Addpass(c,sPASSWORD)
    End If
    sWHEEL1 = LeftShift(sWHEEL1): sWHEEL2 = RightShift(sWHEEL2) 'swheel1左移一位,swheel2右移一位
    Next
    Encrypt_PRO = sRESULT
    End Function

    Function Decrypt_PRO(sINPUT , sPASSWORD )
    Dim sWHEEL1, sWHEEL2
    Dim k, i, c
    Dim sRESULT
    sWHEEL1 = sDefaultWHEEL1: sWHEEL2 = sDefaultWHEEL2
    'ScrambleWheels sWHEEL1, sWHEEL2, sPASSWORD
    sRESULT = ""
    For i = 1 To Len(sINPUT)
    c = Mid(sINPUT, i, 1)
    k = InStr(1, sWHEEL2, c, vbBinaryCompare) '区分大小写
    If k > 0 Then
    sRESULT = sRESULT & Mid(sWHEEL1, k, 1)
    Else
    sRESULT = sRESULT & Addpass(c,sPASSWORD) '得到原始字符
    End If
    sWHEEL1 = LeftShift(sWHEEL1): sWHEEL2 = RightShift(sWHEEL2) '左移右移
    Next
    Decrypt_PRO = sRESULT
    End Function

    Function LeftShift(s )
    If Len(s) > 0 Then LeftShift = Mid(s, 2, Len(s) - 1) & Mid(s, 1, 1)
    End Function

    Function RightShift(s )
    If Len(s) > 0 Then RightShift = Mid(s, Len(s), 1) & Mid(s, 1, Len(s) - 1)
    End Function

    Sub ScrambleWheels(ByRef sW1 , ByRef sW2 , sPASSWORD )
    Dim i ,k
    For i = 1 To Len(sPASSWORD)
    For k = 1 To Asc(Mid(sPASSWORD, i, 1)) * i
    sW1 = LeftShift(sW1): sW2 = RightShift(sW2)
    Next
    Next
    End Sub

    Function Addpass(tStr,tPass)
    'Select Case tStr
    'Case Chr(13)
    'Addpass = tStr
    'Case Chr(10)
    'Addpass = tStr
    'Case Chr(13)+Chr(10)
    'Addpass = tStr
    'Case Chr(9)
    'Addpass = tStr
    'Case Else
    'Addpass = Chr((Asc(tPass) Xor Len(tPass)) Xor Asc(tStr)) 'pass 的asc 码异或psdd的长度再异或 c的asc
    'End Select
    Addpass = tStr
    End Function

    Function ReadFile(FileName)
    Dim fso, f
    Const ForReading = 1, ForWriting = 2, ForAppending = 8
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.OpenTextFile(Server.MapPath(FileName), ForReading, True)
    ReadFile = f.ReadAll
    f.Close
    End Function

    Sub WriteFile(FileName,Str)
    Dim fso, f
    Const ForReading = 1, ForWriting = 2, ForAppending = 8
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.OpenTextFile(Server.MapPath(FileName), ForWriting, True)
    f.Write Str
    f.Close
    End Sub

    %>


    测试文件一

    <%
    
    Rem = Revision:1.00
    Rem = 作者:moson
    
    Rem = mail:guoxp@12365.sd.cn
    
    %>
    
    <!--#include file="Function.asp" -->
    
    <%
    Str = ReadFile("test_back.htm")
    Pass = "moson"
    Encrypt_Str = Encrypt_PRO(Str,Pass)
    Decrypt_Str = Decrypt_PRO(Encrypt_Str,Pass)
    Response.Write Encrypt_Str
    WriteFile "Index.htm",Encrypt_Str
    Response.Write Decrypt_Str
    
    response.write "=========================="
    %>

    测试文件二(可以进行加密解密转化)

    <%
    
    Rem = Revision:1.00
    Rem = 作者:moson
    
    Rem = mail:guoxp@12365.sd.cn
    
    %>
    
    <!--#include file="Function.asp" -->
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>加密解密</title>
    </head>
    
    <body>
    <%
    Pass = Request("txtpass")
    If Pass = Null Then Pass = ""
    %>
    <form name="form1" method="post" action="TestEncrypt.asp">
    请输入要加密的文本:<br>
    <textarea name="txt1" cols="80" rows="10"><%=server.HTMLEncode(Decrypt_PRO(Request("txt2"),Pass))%></textarea>
    <br>
    求得解密文本为:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;密码为:
    <input name="txtpass" type="text" id="txtpass" value="<%=Pass%>">
    <br>
    <textarea name="txt2" cols="80" rows="10"><%=Encrypt_PRO(Request("txt1"),Pass)%></textarea>
    <br><input type="submit" name="Submit" value="加密">
    <input type="submit" name="Submit2" value="解密">
    </form>
    </body>
    </html>
  • 相关阅读:
    mysql索引
    struts升级2.3.12到2.5.13
    springboot使用servlet
    springboot拦截器
    开发复制内容
    Linux常用命令
    Eclipse中文语言包安装和设置中文
    eclipse编写代码所遇到的问题
    permission denied (publickey)问题的解决和向github添加ssh key
    工具
  • 原文地址:https://www.cnblogs.com/computer/p/1781884.html
Copyright © 2020-2023  润新知