VB.NET Hashbytes

Full screen VB.NET Topic list HASHBYTES is a function of SQL Server One way hashing hashbytes('SHA1', @password) TDES

SHA1

In cryptography, SHA-1 (Secure Hash Algorithm 1) is a cryptographic hash function designed by the United States National Security Agency and is a U.S. Federal Information Processing Standard published by the United States NIST. SHA-1 produces a 160-bit (20-byte) hash value known as a message digest. 8+4+4+4+12 in length System.GUID ToString("X2") GUID = Globally Unique Identifier 128Bit Integer = 16 bytes SQL Server datatpe = uniqueidentifier New GUID System.GUID.NewGUID().ToString() GUID = 36 characters in length SHA1 = 40 characters in length ================================================ Dim data(DATA_SIZE) As Byte Dim result() As Byte Dim sha As New SHA1CryptoServiceProvider() ' This is one implementation of the abstract class SHA1. result = sha.ComputeHash(data) ======================================================== UserId | Username | Password | UserGuid -------------------------------------------------------------------------------------- 1 | AlluvialDeposit | mySecretPassword | null 2 | AlluvialDeposit | F032680299B077AFB95093DE4082F625502B8251 | null 3 | AlluvialDeposit | 42444F86F185B7F229DD155E8BCF2A9E6D06453C | E089D2FC-97DB-4DA5-A13C-9FCBBD8B7E95 4 | AlluvialDeposit | D329E99795960F93857CA49D5FB0A8F141C34671 | C6B73B2D-F704-4250-81C4-EFAEC5DB5F54 // From the example above cmd.Parameters.AddWithValue("@password", password); // Now we switch this to: cmd.Parameters.AddWithValue("@password", Security.HashSHA1(password)); Dim strToHash As String strToHash = Command$() Dim sha1Obj As New Security.Cryptography.SHA1CryptoServiceProvider Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash) bytesToHash = sha1Obj.ComputeHash(bytesToHash) Dim strResult As String = "" ========================================================= Copyright © 2015-19 Allied Factors Limited. All Rights Reserved.