Imports System Imports System.IO Imports System.Text.UnicodeEncoding Imports System.Security.Cryptography Public Class frmMain Private Sub txtInput_TextChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles txtInput.TextChanged Dim srcBytes() As Byte = GetEncoding("GB2312").GetBytes(txtInput.Text.tocharArray) 'Dim MS As New MemoryStream(srcBytes) Dim MD5 As New MD5CryptoServiceProvider Dim SHA1 As New SHA1CryptoServiceProvider Dim lvwItem As ListViewItem lvwCode.Items.Clear() Try lvwItem = New ListViewItem("MD5") lvwItem.SubItems.Add(BitConverter.ToString(MD5.ComputeHash(srcBytes)).Replace("-","").ToUpper) lvwCode.Items.Add(lvwItem) lvwItem = New ListViewItem("md5") lvwItem.SubItems.Add(BitConverter.ToString(MD5.ComputeHash(srcBytes)).Replace("-","").ToLower) lvwCode.Items.Add(lvwItem) lvwItem = New ListViewItem("SHA1") lvwItem.SubItems.Add(BitConverter.ToString(SHA1.ComputeHash(srcBytes)).Replace("-","").ToUpper) lvwCode.Items.Add(lvwItem) lvwItem = New ListViewItem("sha1") lvwItem.SubItems.Add(BitConverter.ToString(SHA1.ComputeHash(srcBytes)).Replace("-","").ToLower) lvwCode.Items.Add(lvwItem) lvwItem = New ListViewItem("BASE64-Encode") lvwItem.SubItems.Add(System.Convert.ToBase64String(srcBytes)) lvwCode.Items.Add(lvwItem) lvwItem = New ListViewItem("BASE64-Decode") lvwItem.SubItems.Add(GetEncoding("GB2312").GetString((System.Convert.FromBase64String(txtInput.Text)))) lvwCode.Items.Add(lvwItem) Catch ex As Exception Debug.Print(ex.Message) End Try End Sub Private Sub lvwCode_DoubleClick(ByVal sender As Object,ByVal e As System.EventArgs) Handles lvwCode.DoubleClick Dim sValue As String = lvwCode.FocusedItem.SubItems(1).Text Clipboard.SetText(sValue) End Sub End Class
工程下载地址:http://www.mafom.com/upload/201009091806016458.rar