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 8364067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:20:35+00:00 2026-06-09T12:20:35+00:00

I am generating a random password. My password is 8 characters in length and

  • 0

I am generating a random password. My password is 8 characters in length and it includes the special characters. I need to keep the first letter as alphabet and need to shuffle the remaining seven characters so that it will be a mixture of alphanumeric + ascii characters.

public String generatePassword() {
        int passwordLength = MAX_PASSWORD_LENGTH;
        StringBuffer password = new StringBuffer(passwordLength);
        //first character as an alphabet
        password.append(RandomStringUtils.randomAlphabetic(1)).toString();
        String alphaNumeric = RandomStringUtils.random(5, true, true);
        String asciiChars = RandomStringUtils.randomAscii(2);
        password.append(alphaNumeric).append(asciiChars);
        return password.toString();
    }

I need some help to shuffle the last 7 characters. How to do it?

  • 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-09T12:20:36+00:00Added an answer on June 9, 2026 at 12:20 pm

    The Java Collections API has an inbuilt shuffle method that you can use: see here.
    Basically, you need to create a List from the last 7 characters, and pass it to Collections.shuffle.

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

Sidebar

Related Questions

I have a shell pipeline for generating 10 characters password at random: cat /dev/urandom
i am generating random password. but i want to get phonetic string of the
Generating a random password is easy. but generating a batch is more difficult. public
Standard password security involves generating a random salt for each user, somehow combining that
Possible Duplicate: Java: generating random number in a range I need a little help.
Possible Duplicate: generating random numbers from skewed normal distribution i expect a long array
I'm looking for tools for generating random but realistic text. I've implemented a Markov
How would I go about generating random platforms without intersection? I think garbage collection
I am generating 10 random floats between 6 and 8 (all for good reason),
Possible Duplicate: Algorithm for generating a random number is posible to generate a random

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.