Computing Hash for SHA1

I have received a question asking for How I can compute a SHA1 hash.

You can use this function or similar to get 160bit hash.


Imports
System.Security.Cryptography


    ' Computing Hash for SHA1
    Function SHA1(ByVal dataStream As StringAs Byte()
        Dim Ascii As New ASCIIEncoding
        Dim tmpsource(dataStream.Length) As Byte
        tmpsource = Ascii.GetBytes(dataStream)
        Dim sha As New SHA1CryptoServiceProvider()
        Return sha.ComputeHash(tmpsource)
    End Function

PepLluis,

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>