75 lines
1.8 KiB
Plaintext
75 lines
1.8 KiB
Plaintext
|
GUID Generator - 26 Characters
|
||
|
|
||
|
'Generate 26 charcter Unique ID
|
||
|
Function GetUniqueId()
|
||
|
Dim strUniqueID, GUID
|
||
|
Dim iCount, strBinary, strUniqueChar
|
||
|
'Set GUID = Server.CreateObject("GuidMak
|
||
|
' r.GUID")
|
||
|
Set GUID = Server.CreateObject("GuidMakr.GUID")
|
||
|
strUniqueID = Trim(GUID.GetGUID) 'Returns something like E06019F5A31311D4902B00A0C9ECF1DF
|
||
|
'Remove -, { in the generated number
|
||
|
strUniqueID = Right(Left(Replace(strUniqueID, "-", ""), 33), 32)
|
||
|
'Convert to binary
|
||
|
strBinary = ""
|
||
|
For iCount = 1 To 32
|
||
|
strBinary = strBinary & ConvertHexToBin(Mid(strUniqueID, iCount, 1))
|
||
|
Next
|
||
|
'make it to 130 bit number
|
||
|
strBinary = strBinary & "00"
|
||
|
'Regroup binary into 5bits and convert t
|
||
|
' o number
|
||
|
For iCount = 1 To 130 Step 5
|
||
|
strNo = (CInt(Mid(strBinary, iCount, 1)) * 16) + (CInt(Mid(strBinary, iCount + 1, 1)) * 8) + (CInt(Mid(strBinary, iCount + 2, 1)) * 4) + (CInt(Mid(strBinary, iCount + 3, 1)) * 2) + (CInt(Mid(strBinary, iCount + 4, 1)))
|
||
|
'If greater than 9 convert the number To alphabet. Where A maps to 10
|
||
|
If strNo > 9 Then
|
||
|
strChar = Chr(strNo + 56)
|
||
|
Else
|
||
|
strChar = CStr(strNo)
|
||
|
End If
|
||
|
strUniqueChar = strUniqueChar & strChar
|
||
|
Next
|
||
|
GetUniqueId = strUniqueChar 'Something like T1H1KUE32D8U941C02HDKS7IST
|
||
|
End Function
|
||
|
Function ConvertHexToBin(strHex)
|
||
|
Dim strBin
|
||
|
Select Case UCase(strHex)
|
||
|
Case "0"
|
||
|
strBin = "0000"
|
||
|
Case "1"
|
||
|
strBin = "0001"
|
||
|
Case "2"
|
||
|
strBin = "0010"
|
||
|
Case "3"
|
||
|
strBin = "0011"
|
||
|
Case "4"
|
||
|
strBin = "0100"
|
||
|
Case "5"
|
||
|
strBin = "0101"
|
||
|
Case "6"
|
||
|
strBin = "0110"
|
||
|
Case "7"
|
||
|
strBin = "0111"
|
||
|
Case "8"
|
||
|
strBin = "1000"
|
||
|
Case "9"
|
||
|
strBin = "1001"
|
||
|
Case "A"
|
||
|
strBin = "1010"
|
||
|
Case "B"
|
||
|
strBin = "1011"
|
||
|
Case "C"
|
||
|
strBin = "1100"
|
||
|
Case "D"
|
||
|
strBin = "1101"
|
||
|
Case "E"
|
||
|
strBin = "1110"
|
||
|
Case "F"
|
||
|
strBin = "1111"
|
||
|
Case Else
|
||
|
strBin = ""
|
||
|
End Select
|
||
|
ConvertHexToBin = strBin
|
||
|
End Function
|
||
|
|