VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > VB.net教程 >
  • vb.net加密解密方法

1.vb.net加密解密方法

复制代码
Private Function getLicenseDate() As String
            Dim b() As Byte
            Dim path As String = Server.MapPath(Context.Request.ApplicationPath) & "License\"
            Try
                If Not System.IO.Directory.Exists(path) Then
                    System.IO.Directory.CreateDirectory(path)
                End If
            Catch ex As IO.IOException
                Page.ClientScript.RegisterStartupScript(Me.GetType(), "Alert", "<script>alert('对不起,你可能没有创建文件夹的权限')</script>")
                Exit Function
            End Try
            Dim output As String
            Dim filePath As String = path & "License.dat"
            If File.Exists(filePath) Then
                Try
                    Dim fs As New FileStream(filePath, FileMode.Open)
                    Dim sr As New StreamReader(fs)
                    output = sr.ReadToEnd().ToString()
                    sr.Close()
                    fs.Close()
                    'output = Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(filePath))
                Catch ex As Exception
                    Page.ClientScript.RegisterStartupScript(Me.GetType(), "Alert", "<script>alert('读取LIENCE文件异常!请取消勾选License文件夹下的License.dat的只读属性!')</script>")
                End Try
            Else
                Exit Function
            End If
            Try
                b = Convert.FromBase64String(output)
            Catch ex As Exception
                Page.ClientScript.RegisterStartupScript(Me.GetType(), "Alert", "<script>alert('对不起,,发生错误')</script>")
            End Try
            Try
                output = System.Text.Encoding.GetEncoding(-0).GetString(b)
                Dim startIndex As Integer = output.IndexOf("<ValidityDate>") + "<ValidityDate>".Length
                Dim endIndex As Integer = output.IndexOf("</ValidityDate>")
                Dim index As Integer = endIndex - startIndex
                If startIndex > 0 And endIndex > 0 And index > 0 Then
                    output = output.Substring(startIndex, index)
                Else
                    output = "-1"
                End If
            Catch ex As Exception
                Page.ClientScript.RegisterStartupScript(Me.GetType(), "Alert", "<script>alert('获取License信息发生异常')</script>")
                output = ""
            End Try
            Return output

        End Function
复制代码

 

 

 

2. viewstate 作用域是本页面

出处:https://www.cnblogs.com/WuHZ/p/3230316.html


相关教程