[VB] - BASE64 ENCODE OR DECODE
[VB] - BASE64 ENCODE OR DECODE
Hi mọi người, sau một hồi loay hoay tìm hiểu thủ thuật nhắn tin cho người yêu mà theo phương thức mã hóa tốt nhất để khi nhắn tin người đó sẽ chủ động dịch người lại đoạn mã hóa mà mình gủi cho ngưởi đó để nhắn tin với nhau mà không sợ bị người khác thấy bội dung :D. Và mình dã tìm ra thủ thuật này, nhưng nó bị giới hạn là đoạn nội dung đó không quá dài, và chỉ ngắn gọn súc tích thôi nhé mọi người :D.
Bên dưới là hình ảnh mình viết ra để phục vụ cho mục đích trên.
Mình chưa tích hợp chat messenger của facebook vào để cho tiện cho người dùng nhé mọi người, vì đây là sau quá trình tìm hiểu về thủ thuật và cách để phân tích mã hóa code đó. :D
FULL CODE :
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é.
DOWNLOAD FULL CODE + DEMO
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.
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.