Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8977275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:20:02+00:00 2026-06-15T19:20:02+00:00

Possible Duplicate: Creating a unique alphanumeric 10-character string I need to generate unique random

  • 0

Possible Duplicate:
Creating a unique alphanumeric 10-character string

I need to generate unique random passwords.
So I thought of doing something like MD5(counter+a_random_string+timeInMills) but this has a 32 chars output.
I need a 8 chars passwords.
How can generate unique custom length human-readable passwords?

Update:
I generate N (less that 30) passwords each time and I need these N password be non-redundant. The need of uniqueness is not absolute.
Also checking generated password for repeated value and re-generating it can cause an infinite loop

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:20:03+00:00Added an answer on June 15, 2026 at 7:20 pm

    The brute-force way to guarantee uniqueness of randomly generated strings would be to store all of them and regenerate on collision:

    protected Collection<String> generatedPasswords = new HashSet<String>();
    public String generatePassword(int length) {
      String password = null;
      do {
        StringBuilder buf = new StringBuilder();
        // Append "length" random password characters to "buf".
        password = buf.toString();
      } while (this.generatedPasswords.contains(password));
      return password;
    }
    

    However, if you’re just trying to generate “reasonably” random passwords for end-users, and you’re okay with the occasional (quite rare) collision then you could simply take the first N characters of your MD5 scheme.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHP: How to generate a random, unique, alphanumeric string? I'm creating the
Possible Duplicate: Generate unique random numbers in Java I am creating a lottery app
Possible Duplicate: Creating Nondeterministic functions in SQL Server using RAND() I need to generate
Possible Duplicate: Creating an abstract class in Objective C In Java I like to
Possible Duplicate: Generating Random Numbers in Objective-C Hi I am creating an app where
Possible Duplicate: Creating unique labels in Haskell I've got a datatype Person and some
Possible Duplicate: Creating an abstract class in Objective C I'd like to make abstract
Possible Duplicate: Creating, opening and printing a word file from C++ Hi, I need
Possible Duplicate: Creating a left-arrow button (like UINavigationBar's “back” style) on a UIToolbar I
Possible Duplicate: Selecting Random Rows in MySQL I'm creating a simple web application using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.