Lobby ID Generator Review

Hi there, I’ve made a module that generates “encrypted” IDs for the lobby.

Overview:

local module = {}

function module.CreateLobbyID(IDAmount)
	local random = Random.new()

	local letters = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
	local symbols = {'!','@','#','$','%','^','&','*','(',')','.','?','/','`','~', '_', '-', '=', '+', '{', '}', '[', ']', ';', ':', '"', '|'}
	local IDs = {}

	local function returnRandomLetter()
		return letters[random:NextInteger(1,#letters)]
	end

	local function returnRandomSymbol()
		return symbols[random:NextInteger(1,#symbols)]
	end

	for IDSent = IDAmount, 1, -1 do
		local MinInt = 100000
		local MaxInt = 999999

		local GeneratedSeed = math.random(MinInt, MaxInt)

		-- Encryption
		local ReversedSeed = string.reverse(tostring(GeneratedSeed))
		local CalculatedSeed = tostring(tonumber(ReversedSeed) - GeneratedSeed)

		for i = 1, math.random(1,math.pow(6, 3)) do
			local RandomLetter = returnRandomLetter()
			local RandomSymbol = returnRandomSymbol()

			local Result1 = string.sub(CalculatedSeed, math.random(1,6), math.random(-1,6)) .. RandomLetter .. string.sub(CalculatedSeed, math.random(1,6))
			local Result2 = string.sub(Result1, math.random(1,6), math.random(-1,6)) .. RandomSymbol .. string.sub(Result1, math.random(1,6))

			NewSeed = string.reverse(Result2 .. Result1)
		end

		table.insert(IDs, NewSeed)
	end

	for i, id in pairs(IDs) do
		print(id)
	end
end

return module

I’m not satisfied about how I “encrypted” the IDs, I think it would just not work to prevent against hackers joining matches, but it gets the job done.

Explanation on how it works:

First, it generates a seed that’s random from 100000 to 999999, then make a variable that turns the seed into a string in order to reverse the seed then turn it back to a number to do a calculation like this:

RevSeed - GenSeed

Then turn the calculated seed into a string to begin the process of “encryption”.

For every time until 6^3 (216), Replace 1 to 6 numbers from the calculated seed with a random letter, then do it again except with a random symbol instead.

Then reverse the “encrypted” seed again and place it inside of the IDs table.

Yes, that sounds confusing. So here’s the summary about how it works:

  1. Get a number between 100000 and 999999.
  2. Reverse the number and Subtract that number from the original.
  3. Replace a random amount of 1 to 6 numbers with a random letter, then do the same thing except with a random symbol, 1 to 213 times.
  4. Reverse it again and place it inside of the table named “IDs”.

Conclusion

I think this script needs an overhaul on the “encryption” because it may not be secure, but my head feels light rn so I can’t think of anything other than this abomination.

1 Like

For the IDs amount, it uses the classic for loop.

Why not just use HttpService:GenerateGUID(false) for generating ID’s?
Output: db454790-7563-44ed-ab4b-397ff5df737b

1 Like

i didn’t know you can use httpservice to generate GUIDs(?)

in the future, i may use it and combine it with mine.

1 Like

Fun fact, this is actually what roblox uses for JobId, which is a unique identifier for each server. What do you use your Lobby ID for?

1 Like

originally as a way to make the codes in a way to anger hackers.
now, i’m using it as codes for each lobby

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.