我想将日期时间var编码为8字节的字母数字字符串,稍后可以解码。我不需要太多的安保。
201603301639 -> X5AHY6J9
反之亦然。
数字形式的最高日期值999912312359
适合Double,当转换为Base36时,将输出符合您要求的"CRCPZ21Z"
字符串。
使用这里的编码器功能和这个解码器:
Function base36decode(ByRef base36 As String) As Double
Const alphabet As String = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
base36decode = InStr(1, alphabet, Right(base36, 1), vbTextCompare) - 1
For i = Len(base36) - 1 To 1 Step -1
base36decode = base36decode + 36 ^ (Len(base36) - i) * (InStr(1, alphabet, Mid(base36, i, 1)) - 1)
Next i
End Function
您可以:
x = ConvertBase10(999912312359, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
?x
CRCPZ21Z
?base36decode((x))
999912312359
这是编码,而不是加密。对于弱模糊,只需切换每个例程使用的字母串中的字符顺序,或对输入值执行一些任意运算。