md5解密如何使用到vb程序中在网上搜索VB MD5 会搜索到一大堆MD5的类,
复制到项目中粘贴,
调用的时候使用函数名md5(值) 就可以了!
VB中md5命令函数是什么下面是完整vb.netmd5解密的类vb.netmd5解密,可以设置任意密码
'DES及md5加密解密----添加引用中添加对system.webvb.netmd5解密的引用 。
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
.net中md5具体怎么使用加密和解密?using System;
using System.Text;
using System.Security.Cryptography;
namespace MD5
{
public class MD5
{
// 32 位
public static String Encrypt(String s)
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(s);
bytes = md5.ComputeHash(bytes);
md5.Clear();
string ret = "";
for (int i = 0; ibytes.Length; i)
{
ret= Convert.ToString(bytes[i], 16).PadLeft(2, '0');
}
return ret.PadLeft(32, '0');
}
// 16 位
public static string Encrypt16(string ConvertString)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
string t2 = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(ConvertString)), 4, 8);
t2 = t2.Replace("-", "");
return t2;
}
}
}
-------------------------------------
引用MD5命名空间
using MD5;
直接用MD5.Encrypt(textbox1.Text);即可加密;
MD5没有解密的算法 , 要不然就不用加密了,网上有一些解密的网站 , 有些能解密,有些解密不了 , 有些还需要收费才能解密 。
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
如果要计算文件的就把参数改成字节数组就可以了,然后获取文件GetBytes()传进去就可以了 。
【vb.netmd5解密 vba解密】vb.netmd5解密的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vba解密、vb.netmd5解密的信息别忘了在本站进行查找喔 。
推荐阅读
- ios16主屏幕壁纸锁屏,ios16怎么设置壁纸和锁屏不一样
- 种田经营游戏端游推荐,种田游戏排行
- 关于vuehtml5picker的信息
- c语言函数运算加减法程序 c语言函数加减乘除运算编程代码
- 鸿蒙3系统节省储存空间吗,鸿蒙系统能省多少空间
- Js里面的text所有事件的简单介绍
- 如何观看钉钉在线直播回放,怎样观看钉钉直播回放
- mysql安装以后怎么办 mysql安装完
- 山西门店如何拓客引流模式,山西客户