Files
CHOMPStation2/code/_helpers/guid.dm
2025-09-14 20:05:26 +02:00

20 lines
875 B
Plaintext

/**
* returns a GUID like identifier (using a mostly made up record format)
* guids are not on their own suitable for access or security tokens, as most of their bits are predictable.
* (But may make a nice salt to one)
**/
/proc/GUID()
var/const/GUID_VERSION = "b"
var/const/GUID_VARIANT = "d"
var/node_id = copytext_char(md5("[rand()*rand(1,9999999)][world.name][world.hub][world.hub_password][world.internet_address][world.address][world.contents.len][world.status][world.port][rand()*rand(1,9999999)]"), 1, 13)
var/time_high = "[num2hex(text2num(time2text(world.realtime,"YYYY")), 2)][num2hex(world.realtime, 6)]"
var/time_mid = num2hex(world.timeofday, 4)
var/time_low = num2hex(world.time, 3)
var/time_clock = num2hex(TICK_DELTA_TO_MS(world.tick_usage), 3)
return "{[time_high]-[time_mid]-[GUID_VERSION][time_low]-[GUID_VARIANT][time_clock]-[node_id]}"