Tips and tricks for .NET using ASP and VB code.

Get a Cyclic Redundancy Check of a value

    Private Function GetCrc(ByVal Value As String) As String
        Dim TextBytes As Byte() = System.Text.Encoding.UTF8.GetBytes(Value)
        Dim Md5 As New System.Security.Cryptography.MD5Cng
        Md5.ComputeHash(TextBytes)
        Dim StringBuilderBuffer As New System.Text.StringBuilder
        For Each HashByte As Byte In Md5.Hash
            StringBuilderBuffer.Append(HashByte.ToString("X"))
        Next HashByte
        Return StringBuilderBuffer.ToString
    End Function

No comments:

Post a Comment

Search This Blog