This journey started with a quest to create the shortest possible case-insensitive verification number. Based on the answers there, I worked out a Classic ASP/VBScript implementation of Crockford's Base32 Encoding and it has served me well so far.
Out of semi-idle curiosity, I was wondering if there was a way to further improve the performance. To be clear: it works, and it runs more than fast enough. I am planning to use it more extensively and since I never heard back on a better way, I was hoping for a second set of eyes to say "yes, it's as good as it's going to get" or "here's how to make it more awesome" or whatever.
So you don't have to go back to the latter Stack Overflow question to see the code, here it is:
'Base32 encoding functions for shorter, less confusing verification numbers Const kBase32Digits = "0123456789abcdefghjkmnpqrstvwxyz" Function ToBase32(ByVal lInput) Dim lModulo, sTemp Do Until lInput = 0 lModulo = lInput Mod 32 sTemp = Mid(kBase32Digits, lModulo + 1, 1) & sTemp lInput = lInput \ 32 Loop ToBase32 = sTemp End Function Function FromBase32(ByVal sInput) Dim sTemp, sR, i,iY,lLen, zMultiplier sTemp = LCase(sInput) sTemp = Replace(sTemp,"o","0") sTemp = Replace(sTemp,"i","1") sTemp = Replace(sTemp,"l","1") sTemp = Replace(sTemp,"u","v") zMultiplier = 1 lLen = Len(sTemp) For i = lLen To 1 Step -1 sR = Mid(sTemp, i, 1) iY = InStr(1, kBase32Digits, sR, vbTextCompare) - 1 FromBase32 = FromBase32 + iY * zMultiplier zMultiplier = zMultiplier * 32 Next End Function