How can i write a program that creats a password and a username using Visual Basics 6.0

Dani AI

Generated

asked how to create usernames and passwords in VB6. Replies in the thread leaned toward quick demos () or clarifying intent (, ). The practical gaps not yet covered are secure generation, safe storage, and a simple workflow that fits both a test app and a production scenario.

Recommended workflow (simple to production):

  1. Decide whether usernames are user-entered or auto-generated.
  2. Generate a password with sufficient length and character variety (12+ chars, mixed sets). For production, use a cryptographic RNG (Windows CryptoAPI / CryptGenRandom); for quick demos a seeded Rnd is acceptable but not secure.
  3. Never store plain text. Create a per-user random salt, compute a modern hash (SHA-256 or stronger) of salt+password, and store only salt+hash (base64 or hex) in the database or secure store.
  4. For login, hash the supplied password with the stored salt and compare hashes.
  5. If the password must be communicated, use a secure channel (TLS email link, in-app reset flow) rather than plaintext mail.

Quick VB6 demo generator (non-cryptographic, for local/testing only):

Function GeneratePassword(ByVal Length As Integer) As String
    Dim chars As String
    Dim i As Integer
    Dim pos As Integer
    Dim result As String

    chars = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789!@#$%&*"
    Randomize Timer
    result = ""
    For i = 1 To Length
        pos = Int(Len(chars) * Rnd) + 1
        result = result & Mid$(chars, pos, 1)
    Next i
    GeneratePassword = result
End Function

Notes and cautions:

  • The demo above uses Rnd and is predictable; do not use it for real authentication. For production on VB6, call CryptoAPI (CryptGenRandom) for randomness and use a reliable SHA-2 implementation (via a COM/ActiveX or native API).
  • Avoid hard-coded/static credentials (as suggested in the thread) except for throwaway demos—static values are a security risk.
  • Consider migrating authentication logic to a supported platform (VB.NET, C#, or a server-side service) if security and maintainability matter.

Recommended Answers

All 4 Replies

creates password for what ?

you can get help from any search engine. a lot of sample project wait for you.......lol

if you want to have a simple username and password use static username/password
txtpassword = yourpassword
txtusername = youusername

if any one of that didn't match the value in the textbox, its error or your fail to log in somehow like that

Explain further.
Do you just want to create strings you call password and do nothing with them?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.