Files
Citadel-Station-13-RP/code/controllers/subsystem/mapping/obfuscation.dm
T
siliconsGitHubVM_USER <VM_USER>
94dd2baeb4 sorts file helpers; add directory walk helpers (#4703)
Co-authored-by: VM_USER <VM_USER>
2022-11-12 19:12:09 +01:00

26 lines
969 B
Plaintext

/**
* Obfuscation module
*
* Allows for generating arbitrary obfuscation IDs from static mapload time IDs, that are deterministic within a round.
*/
/datum/controller/subsystem/mapping
/// "secret" key
var/obfuscation_secret
/datum/controller/subsystem/mapping/PreInit()
. = ..()
if(!obfuscation_secret)
obfuscation_secret = md5(GUID())
/**
* Generates an obfuscated but constant ID for an original ID for cases where you don't want players codediving for an ID.
* This is slightly more expensive but is unique for an id/idtype combo, meaning it's safe to reveal - use in cases where you want to allow a player to reverse engineer,
* but want them to find out ICly rather than codedive for an ID
*
* Both original and id_type are CASE INSENSITIVE.
*/
/datum/controller/subsystem/mapping/proc/get_obfuscated_id(original, id_type = "GENERAL")
if(!original)
return // no.
return md5("[obfuscation_secret]%[lowertext(original)]%[lowertext(id_type)]")