TYPE TDZoneInfo
'TIME_DYNAMIC_ZONE_INFORMATION StandardDate
AS SystemTime
DaylightDate
AS SystemTime
TimeZoneKeyName
AS STRING * 256 ' WCHAR128 DynamicDaylightTimeDisabled
AS _BYTE 'BOOLEAN->BYTE
FUNCTION UuidCreate%&
(GUID
AS GUID
) 'Version 4 UUID FUNCTION UuidCreateSequential%&
(GUID
AS GUID
) 'Version 1 UUID
FUNCTION uuiddate$
(BYVAL timestamp~&&
) 'used to extract date from Version 1 UUID
PRINT "4 Sequential Version 1 UUIDs:" PRINT "_______________________________________________" UUID = UUIDVer1
PRINT "Timestamp (Local): "; ExtractTimestamp
(UUID
) PRINT "Clock Sequence : "; ClockSequence
(UUID
) PRINT "UUID Variant : "; UUIDVariant
(UUID
) PRINT "UUID Version : "; UUIDVersion
(UUID
) PRINT "MAC Address : "; MACAddress
(UUID
) PRINT "MAC Vendor : "; MACVendor
(MACAddress
(UUID
)) _DELAY 0.1 'Delay so API doesn't respond with error of too many requests back to back
PRINT "4 Version 3 UUIDs using www.qb64.org as seed:" PRINT "_______________________________________________" UUID = UUIDVer3(1, "www.qb64.org")
PRINT UUID
, "(DNS namespace based)" PRINT "UUID Variant : "; UUIDVariant
(UUID
) PRINT "UUID Version : "; UUIDVersion
(UUID
)
UUID = UUIDVer3(2, "www.qb64.org")
PRINT UUID
, "(URL namespace based)" PRINT "UUID Variant : "; UUIDVariant
(UUID
) PRINT "UUID Version : "; UUIDVersion
(UUID
)
UUID = UUIDVer3(3, "www.qb64.org")
PRINT UUID
, "(OID namespace based)" PRINT "UUID Variant : "; UUIDVariant
(UUID
) PRINT "UUID Version : "; UUIDVersion
(UUID
)
UUID = UUIDVer3(4, "www.qb64.org")
PRINT UUID
, "(x500 namespace based)" PRINT "UUID Variant : "; UUIDVariant
(UUID
) PRINT "UUID Version : "; UUIDVersion
(UUID
)
PRINT "4 Random Version 4 UUIDs:" PRINT "_______________________________________________" UUID = UUIDVer4
PRINT "UUID Variant : "; UUIDVariant
(UUID
) PRINT "UUID Version : "; UUIDVersion
(UUID
)
PRINT "4 Version 5 UUIDs using www.qb64.org as seed:" PRINT "_______________________________________________" UUID = UUIDVer5(1, "www.qb64.org")
PRINT UUID
, "(DNS namespace based)" PRINT "UUID Variant : "; UUIDVariant
(UUID
) PRINT "UUID Version : "; UUIDVersion
(UUID
)
UUID = UUIDVer5(2, "www.qb64.org")
PRINT UUID
, "(URL namespace based)" PRINT "UUID Variant : "; UUIDVariant
(UUID
) PRINT "UUID Version : "; UUIDVersion
(UUID
)
UUID = UUIDVer5(3, "www.qb64.org")
PRINT UUID
, "(OID namespace based)" PRINT "UUID Variant : "; UUIDVariant
(UUID
) PRINT "UUID Version : "; UUIDVersion
(UUID
)
UUID = UUIDVer5(4, "www.qb64.org")
PRINT UUID
, "(x500 namespace based)" PRINT "UUID Variant : "; UUIDVariant
(UUID
) PRINT "UUID Version : "; UUIDVersion
(UUID
)
URLFile = "macvendorrequest"
SHELL _HIDE "curl -G " + CHR$(34) + "https://api.macvendors.com/v1/lookup/" + MAC
+ CHR$(34) + " -H " + CHR$(34) + "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiIsImp0aSI6IjllMmQ0YzYwLTU3NmQtNDI2OC04NDdkLWIyYTUwNGEyM2ZhMCJ9.eyJpc3MiOiJtYWN2ZW5kb3JzIiwiYXVkIjoibWFjdmVuZG9ycyIsImp0aSI6IjllMmQ0YzYwLTU3NmQtNDI2OC04NDdkLWIyYTUwNGEyM2ZhMCIsImlhdCI6MTU5NTkzMzc1OSwiZXhwIjoxOTEwNDI5NzU5LCJzdWIiOiI3NTkyIiwidHlwIjoiYWNjZXNzIn0.9MTN3PlkFxHAokvIKFFtF1aJYdXwjFpC2etMejJ-V4l9NCbT_qhqF-BpNv25h9kpDfntyGWCMXvqs6s9ShEbkw" + CHR$(34) + " -H " + CHR$(34) + "Accept: text/plain" + CHR$(34) + " -o " + URLFile
GET #U
, , macvendorrequest
MACVendor = ""
MACVendor = macvendorrequest
MACAddress
= MID$(UUID
, 25, 2) + "-" + MID$(UUID
, 27, 2) + "-" + MID$(UUID
, 29, 2) + "-" + MID$(UUID
, 31, 2) + "-" + MID$(UUID
, 33, 2) + "-" + MID$(UUID
, 35, 2)
version
= MID$(UUID
, 15, 1) UUIDVersion = "1 (time and node based)"
UUIDVersion = "3 (name based, MD5)"
UUIDVersion = "4 (random data based)"
UUIDVersion = "5 (name based, SHA-1)"
variant
= MID$(UUID
, 20, 1) UUIDVariant = "reserved (NCS backward compatible)"
UUIDVariant = "DCE 1.1, ISO/IEC 11578:1996"
UUIDVariant = "reserved (Microsoft GUID)"
UUIDVariant = "reserved (future use)"
UUIDVariant = "unknown/invalid"
data1
= MID$(UUID
, 16, 3) data2
= MID$(UUID
, 10, 4) timestamp
= VAL("&H" + data1
+ data2
+ data3
) timestamp = timestamp / 10000000 - 12219292800
hours
= timestamp \
3600 MOD 24 'UTC timezone minutes
= timestamp \
60 MOD 60 seconds
= timestamp
MOD 60 DIM UTCTime
AS SystemTime
, loctime
AS SystemTime
, ZoneInfo
AS TDZoneInfo
uuidate = uuiddate(timestamp)
UTCTime.wYear
= VAL(MID$(uuidate
, 1, 4)) UTCTime.wMonth
= VAL(MID$(uuidate
, 6, 2)) UTCTime.wDay
= VAL(MID$(uuidate
, 8, 2)) UTCTime.wDay
= VAL(MID$(uuidate
, 9, 2)) UTCTime.wHour = hours
UTCTime.wMinute = minutes
UTCTime.wSecond = seconds
e~&
= GetDynamicTimeZoneInformation
(_OFFSET(ZoneInfo
)) month = "0" + month
day = "0" + day
hour = "0" + hour
minute = "0" + minute
second = "0" + second
ExtractTimestamp = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second
FUNCTION UUIDVer1$
' Version: 1 (Date & MAC Address) Generated from Date & time and MAC address of network card. Can be security issue. DIM GUID
AS GUID
'Variant: DCE 1.1, ISO/IEC 11578:1996 a%& = UuidCreateSequential(GUID)
UUID
= "0" + HEX$(GUID.Data1
) + "-" UUID
= HEX$(GUID.Data1
) + "-" UUID
= UUID
+ "0" + HEX$(GUID.Data2
) + "-" UUID
= UUID
+ HEX$(GUID.Data2
) + "-" UUID
= UUID
+ "0" + HEX$(GUID.Data3
) + "-" UUID
= UUID
+ HEX$(GUID.Data3
) + "-" UUID
= UUID
+ "0" + HEX$(GUID.Data4
) UUID
= UUID
+ HEX$(GUID.Data4
) UUID
= UUID
+ "0" + HEX$(GUID.Data5
) + "-" UUID
= UUID
+ HEX$(GUID.Data5
) + "-" UUID
= UUID
+ "0" + HEX$(GUID.Data6
) UUID
= UUID
+ HEX$(GUID.Data6
) UUID
= UUID
+ "0" + HEX$(GUID.Data7
) UUID
= UUID
+ HEX$(GUID.Data7
) UUID
= UUID
+ "0" + HEX$(GUID.Data8
) UUID
= UUID
+ HEX$(GUID.Data8
) UUID
= UUID
+ "0" + HEX$(GUID.Data9
) UUID
= UUID
+ HEX$(GUID.Data9
) UUID
= UUID
+ "0" + HEX$(GUID.Data10
) UUID
= UUID
+ HEX$(GUID.Data10
) UUID
= UUID
+ "0" + HEX$(GUID.Data11
) UUID
= UUID
+ HEX$(GUID.Data11
) GUIDHash = UuidHash(GUID, status)
UUIDVer1 = UUID
UUIDVer1 = NilUUID
URLFile = "uuidver3"
URL = "https://www.uuidtools.com/api/generate/v3/namespace/"
URL = URL + "ns:dns/name/"
URL = URL + "ns:url/name/"
URL = URL + "ns:oid/name/"
URL = URL + "ns:x500/name/"
URL = URL + StringToHash
a% = API_request(URL, URLFile)
UUIDVer3 = NilUUID
Data3
= MID$(UUID
, 12, 3) Data4
= MID$(UUID
, 16, 2) Data5
= MID$(UUID
, 18, 2) Data6
= MID$(UUID
, 20, 2) Data7
= MID$(UUID
, 22, 2) Data8
= MID$(UUID
, 24, 2) Data9
= MID$(UUID
, 26, 2) Data10
= MID$(UUID
, 28, 2) Data11
= MID$(UUID
, 30, 2)
GUID.Data1
= VAL("&H" + Data1
): GUID.Data2
= VAL("&H" + Data2
): GUID.Data3
= VAL("&H" + Data3
): GUID.Data4
= VAL("&H" + Data4
): GUID.Data5
= VAL("&H" + Data5
): GUID.Data6
= VAL("&H" + Data6
) GUID.Data7
= VAL("&H" + Data7
): GUID.Data8
= VAL("&H" + Data8
): GUID.Data9
= VAL("&H" + Data9
): GUID.Data10
= VAL("&H" + Data10
): GUID.Data11
= VAL("&H" + Data11
) GUIDHash = UuidHash(GUID, status)
UUIDVer3 = UUID
FUNCTION UUIDVer4$
' Version: 4 (Random) For a truly unique UUID, use this. Can't be duplicated and doesn't reference a MAC address. DIM GUID
AS GUID
'Variant: DCE 1.1, ISO/IEC 11578:1996 a%& = UuidCreate(GUID)
UUID
= "0" + HEX$(GUID.Data1
) + "-" UUID
= HEX$(GUID.Data1
) + "-" UUID
= UUID
+ "0" + HEX$(GUID.Data2
) + "-" UUID
= UUID
+ HEX$(GUID.Data2
) + "-" UUID
= UUID
+ "0" + HEX$(GUID.Data3
) + "-" UUID
= UUID
+ HEX$(GUID.Data3
) + "-" UUID
= UUID
+ "0" + HEX$(GUID.Data4
) UUID
= UUID
+ HEX$(GUID.Data4
) UUID
= UUID
+ "0" + HEX$(GUID.Data5
) + "-" UUID
= UUID
+ HEX$(GUID.Data5
) + "-" UUID
= UUID
+ "0" + HEX$(GUID.Data6
) UUID
= UUID
+ HEX$(GUID.Data6
) UUID
= UUID
+ "0" + HEX$(GUID.Data7
) UUID
= UUID
+ HEX$(GUID.Data7
) UUID
= UUID
+ "0" + HEX$(GUID.Data8
) UUID
= UUID
+ HEX$(GUID.Data8
) UUID
= UUID
+ "0" + HEX$(GUID.Data9
) UUID
= UUID
+ HEX$(GUID.Data9
) UUID
= UUID
+ "0" + HEX$(GUID.Data10
) UUID
= UUID
+ HEX$(GUID.Data10
) UUID
= UUID
+ "0" + HEX$(GUID.Data11
) UUID
= UUID
+ HEX$(GUID.Data11
) GUIDHash = UuidHash(GUID, status)
UUIDVer4 = UUID
UUIDVer4 = NilUUID
URLFile = "uuidver5"
URL = "https://www.uuidtools.com/api/generate/v5/namespace/"
URL = URL + "ns:dns/name/"
URL = URL + "ns:url/name/"
URL = URL + "ns:oid/name/"
URL = URL + "ns:x500/name/"
URL = URL + StringToHash
a% = API_request(URL, URLFile)
UUIDVer5 = NilUUID
Data3
= MID$(UUID
, 12, 3) Data4
= MID$(UUID
, 16, 2) Data5
= MID$(UUID
, 18, 2) Data6
= MID$(UUID
, 20, 2) Data7
= MID$(UUID
, 22, 2) Data8
= MID$(UUID
, 24, 2) Data9
= MID$(UUID
, 26, 2) Data10
= MID$(UUID
, 28, 2) Data11
= MID$(UUID
, 30, 2)
GUID.Data1
= VAL("&H" + Data1
): GUID.Data2
= VAL("&H" + Data2
): GUID.Data3
= VAL("&H" + Data3
): GUID.Data4
= VAL("&H" + Data4
): GUID.Data5
= VAL("&H" + Data5
): GUID.Data6
= VAL("&H" + Data6
) GUID.Data7
= VAL("&H" + Data7
): GUID.Data8
= VAL("&H" + Data8
): GUID.Data9
= VAL("&H" + Data9
): GUID.Data10
= VAL("&H" + Data10
): GUID.Data11
= VAL("&H" + Data11
) GUIDHash = UuidHash(GUID, status)
UUIDVer5 = UUID
NilUUID = "00000000-0000-0000-0000-000000000000"
API_request
= URLDownloadToFileA
(0, URL
+ CHR$(0), File
+ CHR$(0), 0, 0)