Logo

dev-resources.site

for different kinds of informations.

VB .Net: Secure Password

Published at
12/9/2024
Categories
vb
security
cryptography
password
Author
vblover_programmer
Categories
4 categories in total
vb
open
security
open
cryptography
open
password
open
Author
18 person written this
vblover_programmer
open
VB .Net: Secure Password

SecurePassword Class:

Imports System.Text
Imports System.Security.Cryptography
Public Class SecurePassword
    Protected Friend Shared Function GetMd5Hash(ByVal input As String) As String
        ' Create a new instance of the MD5 object.
        Dim md5Hasher As MD5 = MD5.Create()
        ' Convert the input string to a byte array and compute the hash.
        Dim data As Byte() = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input))
        ' Create a new Stringbuilder to collect the bytes
        ' and create a string.
        Dim sBuilder As New StringBuilder()
        ' Loop through each byte of the hashed data 
        ' and format each one as a hexadecimal string.
        Dim i As Integer
        For i = 0 To data.Length - 1
            sBuilder.Append(data(i).ToString("x2"))
        Next i
        ' Return the hexadecimal string.
        Return sBuilder.ToString()
    End Function
    ' Verify a hash against a string.
    Protected Friend Shared Function verifyMd5Hash(ByVal input As String, ByVal hash As String) As Boolean
        ' Hash the input.
        Dim hashOfInput As String = getMd5Hash(input)
        ' Create a StringComparer an compare the hashes.
        Dim comparer As StringComparer = StringComparer.OrdinalIgnoreCase
        If comparer.Compare(hashOfInput, hash) = 0 Then Return True
            Return False
     End Function
End Class

Enter fullscreen mode Exit fullscreen mode

Using for password property to save:

   Public ReadOnly Property Password() As String
        Get
            Return SecurePassword.GetMd5Hash(ConfirmPasswordBox.Text)
        End Get
    End Property

Enter fullscreen mode Exit fullscreen mode

Check for password correction:

If SecurePassword.verifyMd5Hash(Me.PasswordBox.Text,
UserAccount(Me.ID).Password) = False Then
                        Me.PasswordBox.Text = ""
                        .SetError(Me.PasswordBox, "Wrong Password!")
                        Me.PasswordBox.Focus()
                        Me.PasswordBox.Select()
                        Exit Sub
                    End If

Enter fullscreen mode Exit fullscreen mode
cryptography Article's
30 articles in total
Favicon
How to truncate CBC ciphertext
Favicon
Bitflip Attack on CBC: Change of the Ciphertext
Favicon
Introducing Inline Cryptography Toolkit: Simplify Encryption, Decryption, and Hashing in VS Code ๐Ÿš€
Favicon
olssv dvysk!
Favicon
Bitflip Attack on CBC: Change of the IV
Favicon
Exploring Quantum Computing: The Next Frontier in Technology (2025)
Favicon
Como Habilitar o Provedor Legado no OpenSSL 3.x
Favicon
VB .Net: Secure Password
Favicon
C#: Secure Password
Favicon
Enhancing Data Security with MongoDB: A Dive into Cryptography and CSFLE at Ovianta
Favicon
What is Post-Quantum Cryptography (PQC) Migration and How to Secure Data Against Quantum Threats
Favicon
"Behind the Code: How Dark Web Drug Marketplaces Operate and the Developers Who Build Them"
Favicon
The Ultimate Guide to Choosing the Right Cryptography Algorithm for Your Project
Favicon
Lithe Crypt: Simplifying Encryption in PHP Applications
Favicon
Addressing The Threat of Deepfakes With Authentic Images
Favicon
Camouflage-Shield: An Image Encryption Application.
Favicon
Comparing Decentralized Identifiers(DID) Methods
Favicon
Decentralized Identity Simplified: How to Resolve DIDs Effectively
Favicon
Key Management for DIDs in Web5: A Beginnerโ€™s Guide
Favicon
Key Management for DIDs: A Beginner's Journey
Favicon
Understanding Web5 and Its Potential
Favicon
Cryptography in Networking
Favicon
Medium article to explore Post Quantum Cryptography and algorithms comparison
Favicon
Day ??? of learning go. Building cli apps
Favicon
Building Secure and Scalable Blockchain Applications
Favicon
Introduction to Cryptography for Beginners
Favicon
GnuPG and Digital Signatures
Favicon
Cryptography Concepts Simplified
Favicon
The Hitchhikerโ€™s Guide to Building an Encrypted Filesystem in Rust
Favicon
Cryptography #0 - Essential Concepts

Featured ones: