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(-).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 > And endIndex > And index > 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 作用域是本页面

vb.net加密解密方法的更多相关文章

  1. ASP.NET常用加密解密方法

    ASP.NET常用加密解密方法 一.MD5加密解密 1.加密 C# 代码           public static string ToMd5(string clearString)        ...

  2. ios常见加密解密方法

    在其他平台中经常会计算MD5值,在iOS平台中也提供了该方法,首先需要导入头文件 #import <CommonCrypto/CommonDigest.h> 方法CC_MD5可以获取MD5 ...

  3. C#/IOS/Android通用加密解密方法

    原文:C#/IOS/Android通用加密解密方法 公司在做移动端ios/android,服务器提供接口使用的.net,用到加密解密这一块,也在网上找了一些方法,有些是.net加密了android解密 ...

  4. 2019-2-20C#开发中常用加密解密方法解析

    C#开发中常用加密解密方法解析 一.MD5加密算法 我想这是大家都常听过的算法,可能也用的比较多.那么什么是MD5算法呢?MD5全称是 message-digest algorithm 5[|ˈmes ...

  5. Java实现一个简单的加密解密方法

    Crypto是Java语言写的一个简单的加密解密方法. 使用方法: 加密方法 String cipherte=Enande.encrypt(content, pass): 解密方法 Enande.de ...

  6. C#开发中常用的加密解密方法

    转载自:https://www.cnblogs.com/bj981/p/11203711.html C#开发中常用的加密解密方法 相信很多人在开发过程中经常会遇到需要对一些重要的信息进行加密处理,今天 ...

  7. PHP加密解密方法

    加密解密方法 //字符串解密加密 function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) { $ckey_l ...

  8. Javascript实现base64的加密解密方法

    1 function Base64() { 2 // private property 3 _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijkl ...

  9. ASP程序加密/解密方法大揭密

      如今,用ASP技术构建的网站随处可见.由于ASP脚本是在服务器上解释执行的(无法编译),因此你辛苦开发出来的ASP代码,很容易被人拷去任意修改,如何保护ASP源代码呢?这是每个ASP站长都会遇到的 ...

随机推荐

  1. MVC4.0网站发布和部署到IIS7.0上的方法

    最近在研究MVC4,使用vs2010,开发的站点在发布和部署到iis7上的过程中遇到了很多问题,现在将解决的过程记录下来,以便日后参考,整个过程主要以截图形式呈现 vs2010的安装和mvc4的安装不 ...

  2. php操作文件及下载图片脚本

    <?php set_time_limit(0); $handle = fopen('article.txt','r'); for($i=0;$i<1;$i++) { $count = 0; ...

  3. PHP发送邮件的两种方式

    1.用SMTP方式发送邮件.引入phpmailer文件包,然后在文件中 <?php require_once("phpmailer/class.phpmailer.php") ...

  4. 22. Surrounded Regions

    Surrounded Regions Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A ...

  5. 页面打开 抛出w3wp.exe 中发生未处理异常

    页面打开 抛出w3wp.exe 中发生未处理异常

  6. Node.js初探之hello world

    昨天公司内部培训,主讲人王老板对Node.js评价很高,连用几个“变态”来形容,恰好今天周末,有时间来认识下Node.js,对一门新语言最好的认识,是让其输出“hello world”,今天我就利用N ...

  7. 慕课网-安卓工程师初养成-6-5 使用循环操作 Java 中的数组

    来源:http://www.imooc.com/code/1531 实际开发中我们经常使用循环控制数组成员的操作.如: 运行结果: 其中,  用于获取数组的长度 需要注意的“小毛病”: 1. 数组下标 ...

  8. Linux VM acquisition

    The evidence is a VM as below. The flat vmdk is the real disk, and the vmdk only 1kb is just a descr ...

  9. C++中关于string类型究竟能不能用cout输出的问题

    先让我讲下故事哈 一次在MFC中用cout输出一个string类型字符串,编译时出现这样一个错误: error C2679: binary '<<' : no operator defin ...

  10. 【Python】 sorted函数

    我们需要对List.Dict进行排序,Python提供了两个方法对给定的List L进行排序,方法1.用List的成员函数sort进行排序,在本地进行排序,不返回副本方法2.用built-in函数so ...