VB.NET 获取文件MD5值Public Function md5(ByVal a As String) As String
Dim tempmd5 As System.Security.Cryptography.MD5 = New System.Security.Cryptography.MD5CryptoServiceProvider()
Dim bytResult() As Byte = tempmd5.ComputeHash(System.Text.Encoding.Default.GetBytes(a))
Dim strResult As String = BitConverter.ToString(bytResult)
strResult = strResult.Replace("-", "")
Return strResult
End Function
如果要计算文件vb.net文件md5的就把参数改成字节数组就可以vb.net文件md5了vb.net文件md5 , 然后获取文件GetBytes()传进去就可以vb.net文件md5了 。
vb.net 怎么获取一个文件夹所有文件的MD5值VB可使用DriveListBox 控件 , DirListBox 控件和FileListBox 控件组合使用获取文件夹里的文件数量(包括文件夹) 。DriveListBox 控件 在运行时,由于有 DriveListBox 控件,所以可选择一个有效的磁盘驱动器 。
加密解密高手进!VB.NET 谁能给一个MD5或其他的加密算法这个是vb.net文件md5我之前写的 。在需要时调用即可 。
Public Shared Function Encrypt(ByVal Text As String, ByVal sKey As String) As String
Dim provider As New DESCryptoServiceProvider()
Dim bytes As Byte() = Encoding.[Default].GetBytes(Text)
provider.Key = Encoding.ASCII.GetBytes(FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8))
provider.IV = Encoding.ASCII.GetBytes(FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8))
Dim stream As New MemoryStream()
Dim stream2 As New CryptoStream(stream, provider.CreateEncryptor(), CryptoStreamMode.Write)
stream2.Write(bytes, 0, bytes.Length)
stream2.FlushFinalBlock()
Dim builder As New StringBuilder()
For Each num As Byte In stream.ToArray()
builder.AppendFormat("{0:X2}", num)
Next
Return builder.ToString()
End Function
希望能帮到vb.net文件md5你
求VB.NET的MD5算法调用下面是完整的类 , 可以设置任意密码
'DES及md5加密解密----添加引用中添加对system.web的引用 。
Imports System.Security.Cryptography
Imports System
Imports System.Text
Imports System.Web
''' summary
''' DES加密类
''' /summary
''' remarks/remarks
Public Class DESEncrypt
Public Sub DESEncrypt()
End Sub
Public Shared Function Encrypt(ByVal Text As String) As String
Return Encrypt(Text, "12345678")
End Function
Public Shared Function Encrypt(ByVal Text As String, ByVal sKey As String) As String
Dim des As New DESCryptoServiceProvider()
Dim inputByteArray As Byte()
inputByteArray = Encoding.Default.GetBytes(Text)
des.Key = ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8))
des.IV = ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8))
Dim ms As New System.IO.MemoryStream()
Dim cs As New CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write)
cs.Write(inputByteArray, 0, inputByteArray.Length)
cs.FlushFinalBlock()
Dim ret As New StringBuilder()
Dim b As Byte
For Each b In ms.ToArray()
ret.AppendFormat("{0:X2}", b)
Next
Return ret.ToString()
End Function
Public Shared Function Decrypt(ByVal Text As String) As String
Return Decrypt(Text, "12345678")
End Function
Public Shared Function Decrypt(ByVal Text As String, ByVal sKey As String) As String
Dim des As New DESCryptoServiceProvider()
Dim len As Integer
len = Text.Length / 2
Dim inputByteArray(len - 1) As Byte
Dim x, i As Integer
For x = 0 To len - 1
i = Convert.ToInt32(Text.Substring(x * 2, 2), 16)
inputByteArray(x) = CType(i, Byte)
Next
des.Key = ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8))
des.IV = ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sKey, "md5").Substring(0, 8))
Dim ms As New System.IO.MemoryStream()
Dim cs As New CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write)
cs.Write(inputByteArray, 0, inputByteArray.Length)
cs.FlushFinalBlock()
Return Encoding.Default.GetString(ms.ToArray())
End Function
End Class
'以下是调用方法
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '加密
Dim str_Encrypt As String = DESEncrypt.Encrypt("你要加密的文本,可以是任意长度", "密码,可以很长,如果省略这个参数就是默认的12345678")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click '解密
Dim str_Decrypt As String = DESEncrypt.Decrypt("你要解密的文本, 可以是任意长度", "加密时用到的密码,如果省略这个参数就是默认的12345678")
End Sub
【vb.net文件md5 vbnet me】vb.net文件md5的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vbnet me、vb.net文件md5的信息别忘了在本站进行查找喔 。
推荐阅读
- 南充如何进行网络推广赚钱,南充上网用哪个app软件
- u盘文件夹被隐藏怎么恢复,u盘文件夹被隐藏了怎么恢复
- yy每天直播打电话主播,yy每天直播打电话主播知道吗
- 延时函数的c语言 延时函数的c语言是什么
- 电脑发票怎么双面打印不了,发票正反两面都打印了
- 怎么做微信视频号赚钱的方法教程,微信视频号制作技巧
- asp.netwebapi部署,aspnet webapi框架
- php批量生成数据记录 php批量修改数据库数据
- 没有可挖矿的显卡怎么办,没有挖过矿的显卡