Base32 Encoding

Classic ASP/VBScript implementation of Crockford’s Base32 Encoding

'Base32 encoding functions for shorter, less confusing verification numbers'
Const kBase32Digits ="0123456789abcdefghjkmnpqrstvwxyz"
'To Base32'
Function ToBase32(ByVal lInput)
        Dim lModulo, sTemp
        DoUntil lInput =0
                lModulo = lInput Mod32
                sTemp = Mid(kBase32Digits, lModulo +1,1)& sTemp
                lInput = lInput \32
        ToBase32 = sTemp
'From Base32'
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 To1Step-1
                sR = Mid(sTemp, i,1)
                iY = InStr(1, kBase32Digits, sR, vbTextCompare)-1
                FromBase32 = FromBase32 + iY * zMultiplier
                zMultiplier = zMultiplier *32



This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s