Cálculo de algoritmo SHA1

Definición de las funciones necesarias para implementar SHA1


Imports System.Security.Cryptography

…

'' Obtención de firma sha1

sha_str = Me.HashString(info_user_request.DS_MERCHANT_MERCHANTCODE & info_user_request.DS_IDUSER & info_user_request.DS_TOKEN_USER & info_user_request.DS_MERCHANT_TERMINAL & password)

sha_str = Replace(sha_str, "-", "")

info_user_request.DS_MERCHANT_MERCHANTSIGNATURE = sha_str

…

Private Function HashString(ByVal str As String) As String

    Dim sha As SHA1 = New SHA1CryptoServiceProvider()

    Dim hashedValue As String = String.Empty

    Dim hashedData As Byte() = sha.ComputeHash(System.Text.Encoding.ASCII.GetBytes(str))



    hashedValue = BitConverter.ToString(hashedData).ToLower()



    Return hashedValue

End Function