Mammothz

we're just gamers

[VB.NET] การเข้ารหัสข้อความด้วย MD5

1 ความคิดเห็น 2,553 อ่าน

kokaew

สมาชิกทั่วไป

5
กระทู้
4
ความคิดเห็น

22

ระดับสมาชิก: ?
100%

เลื่อนระดับ

ออนไลน์ 4 ชั่วโมง
หมายเลขสมาชิก 2785
โพสต์เมื่อ 15 พฤษภาคม 2559 เวลา 22:55 น.
Imports System.Security.Cryptography
Imports System.Text

   Public Function MD5(ByVal strString As String) As String
       Dim ASCIIenc As New ASCIIEncoding
       Dim strReturn As String
       Dim ByteSourceText() As Byte = ASCIIenc.GetBytes(strString)
       Dim Md5Hash As New MD5CryptoServiceProvider
       Dim ByteHash() As Byte = Md5Hash.ComputeHash(ByteSourceText)

       strReturn = ""

       For Each b As Byte In ByteHash
           strReturn = strReturn & b.ToString("x2")
       Next
       Return strReturn
   End Function

b.ToString("x2" หมายถึง แปลงจาก byte เป็น string ด้วย format "x2" ซึ่ง x2 คือ เลขฐานสิบหก

เครดิต : tungman และ TC Admin จากเว็บไซร์ Thaicreate.com

แก้ไขล่าสุดเมื่อ 15 พฤษภาคม 2559 เวลา 22:56 น.

PSK1991

สมาชิกทั่วไป

0
กระทู้
5
ความคิดเห็น

0

ระดับสมาชิก: 1
100%

เลื่อนระดับ

ออนไลน์ 1 ชั่วโมง
หมายเลขสมาชิก 144507
โพสต์เมื่อ 10 กรกฎาคม 2562 เวลา 23:10 น.
ความคิดเห็นที่ 1
burnขอบคุณมากครับ 

กรุณายืนยันว่าคุณไม่ใช่บอทหรือสแปม