Bên dưới là hình ảnh mình viết ra để phục vụ cho mục đích trên.
FULL CODE :
Imports System.Net Imports System.IO Imports System.Net.Mail Imports System.Threading Imports System.Security.Cryptography Imports System.Text Public Class Form1 #Region "PANEL MOVING" Dim drag As Boolean Dim mousex As Integer Dim mousey As Integer Private Sub Panel2_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) drag = True mousex = Windows.Forms.Cursor.Position.X - Me.Left mousey = Windows.Forms.Cursor.Position.Y - Me.Top End Sub Private Sub Panel2_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) If drag Then Me.Top = Windows.Forms.Cursor.Position.Y - mousey Me.Left = Windows.Forms.Cursor.Position.X - mousex End If End Sub Private Sub Panel1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Panel1.MouseDown drag = True mousex = Windows.Forms.Cursor.Position.X - Me.Left mousey = Windows.Forms.Cursor.Position.Y - Me.Top End Sub Private Sub Panel1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Panel1.MouseMove If drag Then Me.Top = Windows.Forms.Cursor.Position.Y - mousey Me.Left = Windows.Forms.Cursor.Position.X - mousex End If End Sub Private Sub Panel2_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) drag = False End Sub Private Sub Panel1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Panel1.MouseUp drag = False End Sub Dim textbytes, encryptedtextbytes As Byte() Dim rsa As New RSACryptoServiceProvider Dim encoder As New UTF8Encoding Dim encrypted, TextToDecrypt, TextToEncrypt, decrypted As String Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try TextToEncrypt = TextBox1.Text encrypt() TextBox2.Text = encrypted ' TextBox2.Enabled = True Button3.Enabled = True Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Try TextToDecrypt = TextBox1.Text decrypt() TextBox2.Text = decrypted Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub #End Region Sub encrypt() 'Use UTF8 to convert the text string into a byte array textbytes = encoder.GetBytes(TextToEncrypt) 'encrypt the text encryptedtextbytes = rsa.Encrypt(textbytes, True) 'Convert the encrypted byte array into a Base64 string for display purposes encrypted = Convert.ToBase64String(encryptedtextbytes) End Sub Sub decrypt() encryptedtextbytes = Convert.FromBase64String(TextToDecrypt) 'get the decrypted clear text byte array textbytes = rsa.Decrypt(encryptedtextbytes, True) 'convert the byte array to text using the same encoding format that was used for encryption decrypted = encoder.GetString(textbytes) End Sub Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click End End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click My.Computer.Clipboard.SetText(TextBox2.Text) Label4.Text = "Copy Successfull" End Sub End Class
Trong đoạn code trên mình có tích hợp thêm mã code FLAT UI để làm đẹp cho giao diện nhé mọi người, nếu ai không thích thì có thể loại bỏ code đó ra để tối ưu thủ thuật này thật tốt nhé.
MẬT KHẨU GIẢI NÉN: hungqb.com
Chúc mọi người thành công với thủ thuật đơn giản này.