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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:28:48+00:00 2026-05-11T08:28:48+00:00

Client has an simple increasing order number (1, 2, 3…). He wants end-users to

  • 0

Client has an simple increasing order number (1, 2, 3…). He wants end-users to receive an 8- or 9- digit (digits only — no characters) ‘random’ number. Obviously, this ‘random’ number actually has to be unique and reversible (it’s really an encryption of the actualOrderNumber).

My first thought was to just shuffle some bits. When I showed the client a sample sequence, he complained that subsequent obfuscOrderNumbers were increasing until they hit a ‘shuffle’ point (point where the lower-order bits came into play). He wants the obfuscOrderNumbers to be as random-seeming as possible.

My next thought was to deterministically seed a linear congruential pseudo-random-number generator and then take the actualOrderNumber th value. But in that case, I need to worry about collisions — the client wants an algorithm that is guaranteed not to collide in at least 10^7 cycles.

My third thought was ‘eh, just encrypt the darn thing,’ but if I use a stock encryption library, I’d have to post-process it to get the 8-or-9 digits only requirement.

My fourth thought was to interpret the bits of actualOrderNumber as a Gray-coded integer and return that.

My fifth though was: ‘I am probably overthinking this. I bet someone on StackOverflow can do this in a couple lines of code.’

  • 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. 2026-05-11T08:28:49+00:00Added an answer on May 11, 2026 at 8:28 am

    Pick a 8 or 9 digit number at random, say 839712541. Then, take your order number’s binary representation (for this example, I’m not using 2’s complement), pad it out to the same number of bits (30), reverse it, and xor the flipped order number and the magic number. For example:

    1         = 000000000000000000000000000001  Flip      = 100000000000000000000000000000 839712541 = 110010000011001111111100011101 XOR       = 010010000011001111111100011101 = 302841629  2         = 000000000000000000000000000010  Flip      = 010000000000000000000000000000 839712541 = 110010000011001111111100011101 XOR       = 100010000011001111111100011101 = 571277085 

    To get the order numbers back, xor the output number with your magic number, convert to a bit string, and reverse.

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

Sidebar

Ask A Question

Stats

  • Questions 136k
  • Answers 136k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It depends on the order of data member declarations in… May 12, 2026 at 7:11 am
  • Editorial Team
    Editorial Team added an answer The documentation for condp says: A single default expression can… May 12, 2026 at 7:11 am
  • Editorial Team
    Editorial Team added an answer Encoding is done through Transformer. The Transformer may use instructions… May 12, 2026 at 7:11 am

Related Questions

Client has an simple increasing order number (1, 2, 3...). He wants end-users to
As recently as several years ago, the developers actually made the builds that went
This question is relating to a specific functionality that a client has requested for
We are making a lab instrument using an ARM9/RTOS system. The client has asked
I have an ASP.NET 3.5 e-commerce site that has an admin section. I want

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.