最常用的加密类
 1 Imports System.Security.Cryptography
Imports System.Security.Cryptography
2 Imports System.Text
Imports System.Text
3 Imports System.Text.RegularExpressions
Imports System.Text.RegularExpressions
4 Public Class Security
 Public Class Security
5
6 '*********************************************************************
        '*********************************************************************
7 '
        '
8 ' Security.Encrypt() Method
        ' Security.Encrypt() Method
9 '
        '
10 ' The Encrypt method encryts a clean string into a hashed string
        ' The Encrypt method encryts a clean string into a hashed string
11
12 '
        '
13 '*********************************************************************
        '*********************************************************************
14 Public Shared Function Encrypt(ByVal cleanString As String) As String
        Public Shared Function Encrypt(ByVal cleanString As String) As String
15 Dim clearBytes As [Byte]()
            Dim clearBytes As [Byte]()
16 clearBytes = New UnicodeEncoding().GetBytes(cleanString)
            clearBytes = New UnicodeEncoding().GetBytes(cleanString)
17 Dim hashedBytes As [Byte]() = CType(CryptoConfig.CreateFromName("MD5"), HashAlgorithm).ComputeHash(clearBytes)
            Dim hashedBytes As [Byte]() = CType(CryptoConfig.CreateFromName("MD5"), HashAlgorithm).ComputeHash(clearBytes)
18 Dim hashedText As String = BitConverter.ToString(hashedBytes)
            Dim hashedText As String = BitConverter.ToString(hashedBytes)
19 Return hashedText
            Return hashedText
20 End Function
        End Function
21
22 End Class
    End Class
23
 Imports System.Security.Cryptography
Imports System.Security.Cryptography2
 Imports System.Text
Imports System.Text3
 Imports System.Text.RegularExpressions
Imports System.Text.RegularExpressions4
 Public Class Security
 Public Class Security5

6
 '*********************************************************************
        '*********************************************************************7
 '
        '8
 ' Security.Encrypt() Method
        ' Security.Encrypt() Method9
 '
        '10
 ' The Encrypt method encryts a clean string into a hashed string
        ' The Encrypt method encryts a clean string into a hashed string11

12
 '
        '13
 '*********************************************************************
        '*********************************************************************14
 Public Shared Function Encrypt(ByVal cleanString As String) As String
        Public Shared Function Encrypt(ByVal cleanString As String) As String15
 Dim clearBytes As [Byte]()
            Dim clearBytes As [Byte]()16
 clearBytes = New UnicodeEncoding().GetBytes(cleanString)
            clearBytes = New UnicodeEncoding().GetBytes(cleanString)17
 Dim hashedBytes As [Byte]() = CType(CryptoConfig.CreateFromName("MD5"), HashAlgorithm).ComputeHash(clearBytes)
            Dim hashedBytes As [Byte]() = CType(CryptoConfig.CreateFromName("MD5"), HashAlgorithm).ComputeHash(clearBytes)18
 Dim hashedText As String = BitConverter.ToString(hashedBytes)
            Dim hashedText As String = BitConverter.ToString(hashedBytes)19
 Return hashedText
            Return hashedText20
 End Function
        End Function21

22
 End Class
    End Class23

 
                    
                     
                    
                 
                    
                
 
 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号