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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:16:37+00:00 2026-05-23T15:16:37+00:00

I am trying to generate a unique identifier of a fixed length such as

  • 0

I am trying to generate a unique identifier of a fixed length such as the IDs that are generated by Megaupload for the uploaded files.

For example:

  • ALGYTAB5
  • BCLD23A6

In this example using from A-Z and 0-9 and with a fixed length of 8 the total different combinations are 2,821,109,907,456.

What if one of the generated id is already taken. Those ids are going to be stored in a database and it shouldn’t be used more than once.

How can I achieve that in Java?

Thank you.

  • 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-05-23T15:16:38+00:00Added an answer on May 23, 2026 at 3:16 pm

    Hmm… You could imitate a smaller GUID the following way. Let first 4 bytes of your string be the encoded current time – seconds passed after Unix. And the last 4 just a random combination. In this case the only way two ID’s would coincide is that they were built at the same second. And the chances of that would be very veeery low because of the other 4 random characters.

    Pseudocode:

    get current time (4 byte integer
    id[0] = 1st byte of current time (encoded to be a digit or a letter)
    id[1] = 2nd
    id[2] = 3rd
    id[3] = 4th
    id[4] = random character
    id[5] = random character
    id[6] = random character
    id[7] = random character
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to generate unique IDs for each modal, as I will be
i am trying to generate unique subsets of length 3 from integers ranging from
I'm trying to generate a unique ID in php in order to store user-uploaded
I am trying to generate unique values in c# with the help of DateTime
I'm trying to generate 16 000 000 unique random numbers (10-digits: range 1 000
I am trying to understand crc32 to generate the unique url for web page.
I'm trying to generate a report of the activities that users have done within
Im trying to generate n unique random numbers between 1 and max I tried
Trying to generate, from a list of chars, a list of unique chars mapped
i'm trying to generate a unique id using this code: $RCode = md5(uniqid(rand(), true));

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.