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

  • Home
  • SEARCH
  • 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 6468385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:53:06+00:00 2026-05-25T05:53:06+00:00

We are using MySQL and developing an application where we’d like the ID sequence

  • 0

We are using MySQL and developing an application where we’d like the ID sequence not to be publicly visible… the IDs are hardly top secret and there is no significant issue if someone indeed was able to decode them.

So, a hash is of course the obvious solution, we are currently using MD5… 32bit integers go in, and we trim the MD5 to 64bits and then store that. However, we have no idea how likely collisions are when you trim like this (especially since all numbers come from autoincrement or the current time). We currently check for collisions, but since we may be inserting 100.000 rows at once the performance is terrible (can’t bulk insert).

But in the end, we really don’t need the security offered by the hashes and they consume unnecessary space and also require an additional index… so, is there any simple and good enough function/algorithm out there that guarantees one-to-one mapping for any number without obvious visual patterns for sequential numbers?

EDIT: I’m using PHP which does not support integer arithmetic by default, but after looking around I found that it could be cheaply replicated with bitwise operators. Code for 32bit integer multiplication can be found here: http://pastebin.com/np28xhQF

  • 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-25T05:53:06+00:00Added an answer on May 25, 2026 at 5:53 am

    You could simply XOR with 0xDEADBEEF, if that’s good enough.

    Alternatively multiply by an odd number mod 2^32. For the inverse mapping just multiply by the multiplicative inverse

    Example: n = 2345678901; multiplicative inverse (mod 2^32): 2313902621
    For the mapping just multiply by 2345678901 (mod 2^32):

    1 –> 2345678901
    2 –> 396390506

    For the inverse mapping, multiply by 2313902621.

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

Sidebar

Related Questions

I am developing a web application using GXT, Hibernate, mysql etc. There is a
I am developing Desktop application using c#.net and MySql. Is there any solution to
I am developing a PHP/MySQL application using vertrigoserver. I need to enter the German
I'm developing a J2EE 6 Web Application, using a MySql 5.02 DataBase. I'm trying
I am using PHP and Mysql for developing an application. we have two copies
I am currently developing an application using C# and a MySQL Database Backend. My
I'm currently developing a web application using MYSQL database InnoDB format and need some
I am developing a web application with ASP.NET and MySQL, but I am not
I am developing an MVC application using a mysql database. I searched a lot
I am developing a web application using php and mysql. This application runs on

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.