从the first part of my problem开始,我正在尝试编写Douglas Crockford's Base32 Encoding的经典ASP / VBScript实现。
这个特定项目的时间紧迫,所以当我独自完成这项工作时,我希望有人随手拿着东西(或者至少可以鞭打一下)。
答案 0 :(得分:0)
首先运行......这看起来是对的吗?
'Base32 encoding functions for shorter, less confusing verification numbers'
Const kBase32Digits = "0123456789abcdefghjkmnpqrstvwxyz"
'To Base32'
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
'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 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
编辑:到目前为止似乎工作正常......除非有人发布更好的内容,否则我会继续这样做。