views:

105

answers:

3

This is going to be a little long and rambly, but I want to make sure everything is in the proper context.

Back in 2004 I wrote an online Learning Management System using Classic ASP and VBScript. I'm now working on some upgrades (and periodically asking myself WTF I was thinking when I wrote various segments of code...), and I want to take this opportunity to resolve one of the frequent complaints I get - the size of the verification numbers.

When you complete a test online, a verification number is displayed so if you needed to re-create your certificate of completion (its a hospital, and trying to get them to get rid of their paper is like asking Linus to give up his blanket) you can enter the number, etc. etc.

At the time I wrote it (and sadly still to this day) there is no unique identifier I can use to create a transcript page - so please don't post suggestions to that end. There's more going on than I care to get into, and I want to head off valid suggestions that I can't use. ;)

The verification number is a concatenation of various pieces of information (mostly because when I first wrote it I was an idiot newb and SO wasn't around), and while it is a much-appreciated feature there are a lot of complaints about how long the number is. Returning the raw ID at this point is no better as we're in the 6-digit range.

My initial idea was to use a Base64 encoding algorithm I got from elsewhere, but given the problems I've had with just numbers, I'm thinking changing it to a case-sensitive value is only asking for a different class of problems... which brings me to the question at hand:

What can I use to create the shortest possible case-insensitive verification number since hex won't reduce the length appreciably?

And as the tags indicate, I need to be able to implement it in ASP Classic/VBScript - migration is not an option at this point.

Edit: based on the answers, I found a link to Crockfor's implementation of Base32, which looks like what I'm looking for - http://www.crockford.com/wrmg/base32.html

+3  A: 

Base36?

Edit: As Lucky mentions in the comments, using Base36 probably doesn't give any real advantage over Base32 in this situation.

LukeH
+1. But also consider base 33, which avoids another possible source of errors by not using the letters I, L and O (but *does* accept them as input, O = 0, L = I = 1).
Todd Owen
@Todd: My original answer suggested Base32, but then I re-read the question and noticed that the OP asked for the "shortest possible" encoding.
LukeH
A 4 character base-32 can represent any 6 digit number, a 3-digit base-36 can't, so "shortest" possible is the same in this problem space.
Lucky
I'm going to go with the Base32 option. Now to work on implementation... I'll save that for a new question.
AnonJr
A: 

case insensitive letters and numbers? you need a base (26 + 10) converter I think...

mcintyre321
A: 

How about using Huffman Coding on a binary representation of the concatenation of the information in the certificate? Then return the result as a decimal number.

Peter
I really like this answer. I wouldn't actually do it, nor would I recommend it, but it has a certain flair.
Lucky