Unique identifiers that are user-friendly and difficult to understand

My team is working on a legacy database application that uses two different values โ€‹โ€‹as unique identifiers for a Group object: Id

is an auto-incrementing Identity column whose value is determined by the database when inserted. GroupCode

is determined by the application after insertion and "Group" + theGroup.Id

.

We need an algorithm to generate the GroupCode that:

  • Are unique.
  • It is easy enough for the user to enter text.
  • It's hard for a hacker to guess.
  • Either created in the database on insert, or created by the application prior to insertion (that is, independent of the identity column).

the existing solution meets the first two criteria, but not the last two. Does anyone know of a good solution to meet all of the above criteria?

One more note. Even though this code is used by external users, and even though the Id would be better at identifying other tables to bind their foreign keys, GroupCode is used by other tables to refer to a specific group.

Thanks in advance.

+2


source to share


2 answers


Can a new column be added? It can consist of Identity and a random 32-bit number.

Then this 64-bit number could be translated into "Memorable Random String". It wouldn't be perfect security, but it could be good enough.

Here is an example using Ruby and Koremutake gem .

require 'koremu'
# http://pastie.org/96316 adds Array.chunk
identity=104711
r=rand(2**32)<<32 # in this example 5946631977955229696
ka = KoremuFixnum.new(r+identity).to_ka.chunk(3)
ka.each {|arr| print KoremuArray.new(arr).to_ks + " "}

      



Result:

TUSADA REGRUMI LEBADE

Also check out Password Generation Algorithms Using Phonetically Memorable Files .

+1


source


Have you looked into Base32 / Base36 content encoding? The Base32 view of the Ident32 column will make it unique, easy to type, but definitely not secure. However, most non-programmers have no idea how the string value is generated.



Also by using Base32 / 36 you can support regular primary keys based on integer databases.

+1


source







All Articles