Generate guaranteed unique number from given inputs that is only 7 digits

103 Views Asked by At

The short version: How can I use minutes since a recent date and 2 sets of known numbers from 0-255 to guarantee a unique 7 digit number?

Long version: I'm trying to generate a unique number or string that is guaranteed to be unique for at least 5 years, preferably 10 years that will only be 7 digits. This is for naming computers hostnames in AWS and we have servers that come and go daily based on need. The maximum a windows hostname can be is 15 characters and my company requires the first 8 characters be set, so I only have 7 characters to use to guarantee uniqueness.

What I've figured out so far is that I will take the number of minutes since January 1st, 2018 and convert it to Base32, which takes of the first 5 characters.

Now, that leaves me with the final 2 characters. I'm trying to use an attribute of the server that I know won't conflict, which is the private IP address. I'm trying to use the last 2 octets of the private IP address. The last 2 octets of the IP address can be 0 - 255.

Is there some mathematical operation I can do to the last 2 octets of the IP address or combine them in some way with the number of minutes since Jan 1, 2018 that would guarantee uniqueness?