25
août
2008
Crypter des mots de passe en toute simplicité
août
2008
L’algorithme MD5, pour Message Digest 5, est une fonction de hachage cryptographique très populaire.
La génération du cryptage en MD5 sous VB .Net est simple en voici le code :
'Ne pas oublier l'import
Imports System.Security.Cryptography
Function CalculMD5Hash(ByVal FileContent As String) As String
Dim arHash As Byte() = New
MD5CryptoServiceProvider().ComputeHash(ASCIIEncoding.ASCII.GetBytes(FileContent)
Return ByteArrayToString(arHash)
End Function
Function ByteArrayToString(ByVal arrInput() As Byte) As String
Dim i As Integer
Dim sOutput As New StringBuilder(arrInput.Length)
For i = 0 To arrInput.Length - 1
sOutput.Append(arrInput(i).ToString("X2"))
Next
Return sOutput.ToString()
End Function
Imports System.Security.Cryptography
Function CalculMD5Hash(ByVal FileContent As String) As String
Dim arHash As Byte() = New
MD5CryptoServiceProvider().ComputeHash(ASCIIEncoding.ASCII.GetBytes(FileContent)
Return ByteArrayToString(arHash)
End Function
Function ByteArrayToString(ByVal arrInput() As Byte) As String
Dim i As Integer
Dim sOutput As New StringBuilder(arrInput.Length)
For i = 0 To arrInput.Length - 1
sOutput.Append(arrInput(i).ToString("X2"))
Next
Return sOutput.ToString()
End Function
Exemple de Hash pour le texte developpez.com = 3D3FC4FE47FF212A71E4237EBA6DA61A