Integer ID obfuscation techniques

后端 未结 10 1589
萌比男神i
萌比男神i 2020-12-06 07:14

I\'m looking for an easy and reversible method of obfuscating integer IDs. Ideally, I\'d want the resulting obfuscation to be at most eight characters in length and non-seq

10条回答
  •  旧时难觅i
    2020-12-06 07:38

    If you've only got about 10,000 integers then the easiest and most reliably way would probably be a mapping table between the integer and a randomly generated string. Either generate a bunch of random identifiers up-front that correspond to each integer, or just fill them in on demand.

    This way you can guarantee no collisions, and don't have to worry about encryption because there's nothing to decrypt as the strings are not derived from the integers themselves.

    You could implement it in a database table or in memory (e.g. a two-way dictionary) depending on your needs.

提交回复
热议问题