I am looking to create a unique id of a maximum of 11 characters out of up to 24 characters
transaction_id : 8N110858X42689420
the transaction id needs to be converted to a max of 11 characters.
any way to keep it’s uniqueness?
TIA
I am looking to create a unique id of a maximum of 11 characters out of up to 24 characters
transaction_id : 8N110858X42689420
the transaction id needs to be converted to a max of 11 characters.
any way to keep it’s uniqueness?
TIA
It would help to know what each position of the transaction mean to determine the total combinations. Or is it just 36^24?
I am looking to create a unique id of a maximum of 11 characters out of up to 24 characters
<<
Why?
Usually this question stems from trying to put a long UID into a database field that ‘only has space for’ a short one.
if you create a lookup table, you can create a UID for each row, and store the SN as a field.
eg
UID / TRANSID
82736373 = 8N110858X42689420
72363634 = 7N118278X42614240
From that, you can find the trans ID from the UID, and vice versa.
Trying to byte pack:
If the UID doesnt have to be human readable, the smallest number of bits that will hold 36 possible values (numbers and capital letters A to Z) , is 6
So with some packing into a binary string, the shortest non-lossy version of the trans ID would be 24 * 6/8 bytes = 18 bytes and therefore still too long.
If not all letters can appear, and you could restrict the range to 32 characters, then the minimum size is
24 * 5/8 = 15 … still too long for an 11 character space
So to truly restrict the UID to 11 chars, you need to be able to identify redundancies in the original trans ID
For example, all transID may start with 8N11, and if so, that can be discarded before packing.