Implement MD5 encryption with VB.NET

zhaozj2021-02-16  112

Imports

System.text

Imports

System.security.cryptography.cryptography

Public

Class Form1

Class Form1 Inherits System.Windows.Forms.Form # Region "Windows Form Designer Generated Code" Public Sub New () Sub New () MyBase.new () 'This call is required for the Windows Form Designer. InitializationComponent () 'Add any initialized End Sub' form to clean up the component list after the initializeComponent () call. Protected Overloads Overrides Sub Dispose () Sub Dispose (ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose () End If End If MyBase.Dispose (disposing) End Sub 'Windows Form Designer Required Private Components as System.comPonentModel.icontainer 'Note: The following procedure is necessary to use the Windows Form Designer to modify this process using the Windows Form Designer. 'Don't modify it using the code editor.

Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Private Sub InitializeComponent () Sub InitializeComponent ( ) Me.TextBox1 = New System.Windows.Forms.TextBox Me.TextBox2 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout () '' TextBox1 'Me.TextBox1. Location = new system.drawing.point (32, 56) Me.TextBox1.name = "textbox1" me.textbox1.size = new system.drawing.size (144, 21) me.textbox1.tabindex = 0 me.TextBox1. TEXT = "" '' TextBox2 'me.textbox2.location = new system.drawing.point (32, 96) me.textbox2.name = "textbox2" me.textbox2.size = new system.drawing.size (224, 21 ) Me.TextBox2.TabINDEX = 1 me.textbox2.text = "" '' B Utton1 'me.button1.location = new system.drawing.point (184, 56) me.button1.name = "button1" me.button1.tabindex = 2 me.button1.text = "Button1"' FORM1 'ME. AutoScaleBaseSize = new system.drawing.size (6, 14) me.clientsize = new system.drawing.size (472, 285) me.controls.add (me.button1) me.controls.add (me.textbox2) me. Controls.add (me.textbox1) me.name = "form1" me.text = "md5"

Me.ResumeLayout (False) End Sub # End Region Private Sub Button1_Click () Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim md5 As New MD5CryptoServiceProvider Dim username As Byte () = ( new ASCIIEncoding) .GetBytes (TextBox1.Text) 'is converted to a hash value Byte array Dim mdByte as Byte () = md5.ComputeHash (username)' Dim mdString as String = System.BitConverter.ToString (mdByte) Dim mdString as String = (New ASCIIEncoding) .GetString (mdByte) TextBox2.Text = mdString End Sub Private Sub Form1_Load () Sub Form1_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End SubEnd ClassSystem.Security.Cryptography this Categories need to be referenced, it provides security services, used for MD5 just a furk

转载请注明原文地址:https://www.9cbs.com/read-11024.html

New Post(0)