Random String Generator

Why not utilize math.random() and pass the resulting number into the string.char() method instead of manually typing out all possible characters?

1 Like

Alternatively you could just do

local String = ""

for _ = 0, Length do
   String = String .. string.char(math.random(97, 122))
end
2 Likes

My face when

local RandomString = (function() local t = {}; for i = 0, math.random(0, 1000) do table.insert(t, utf8.char(math.random(1, 1114111))) end; return table.concat(t, ""); end)()

warn(RandomString) --> 򎳃󄛈񬗌񒥺􉞕񗾮񃊒򽏈󗻲󫎹𨃇󰄩𻿟󒐛󓴸򳢯񌺗𠐝󌱬𩓱􏁆𣜜󴗽񎲑暊󾠘򰝰򧩲񅦳󪁒񿳜𓊨񎰈򀩢𖃘򶛅𜰲򎢘򾊒󤩖񣪧􃡓󂜬𣏟󰎿󚀹𫡬􂥙򼣆񲸸񷱅򹉡򡿦򳱑爈򵞍􇷍𕜁򃯺򖪜񹚐񧛼󔑻򜧬䏁򛀎򃶲𯽛򤏀򬫅􄍐󊨮򈟟𥯪򪚘񞵚򽴒񎗝񃣻󫧇💃帓򖴏󷹌򷗶򫰐𓋀򶶡𥁤󍞒񁣬񮞡񟭕򍮏􉖶򼛌󵥤񆈸󾦶𦼤𐤛򀉣𲽢􆙍ⷒ񻳋󑒄󧪇𳻹𚂟򉗄񊮫񱵉󨁦󎎮񛹧󪤖𭜔󻐆󢦿𞔂񘛡𚄻砮򄨹𨧸򁖝󡉔ኚ򎃄򓺝񥆽򆃸񋟤򚯒񝟗򼫸񳌁󧢌𛛽𱆆񐒧򺝊􅘬󳺉󑄀𳀙󻂲і󸱁񺨼󋫷񃨜񸅇򠵿𱎆򤧺񧅍􂩒򓧓񝻈𐁸򞸽󗐴񍃄𻖺􆙖뀕򹫾򐒴Ƀ𧿔񐌛㏒񛛉󓎴򭄻󽆵񣼢񊢑񓝜􊚍񼝹󆝝򅱚󅷵񅋒񿩳𯫝򫝱򁕂󉚪󅰿񍔨򍽢󁒥

Readable code be like

local randomString = game:GetService("HttpService"):GenerateGUID()

This is a GUID, not a random string since it has the {} and dashes (i forgot the name mbmb)

if you want a TRULY random string, use the utf8 library

local randomString = string.gsub(game:GetService("HttpService"):GenerateGUID(false), "-", "")

2 Likes

As I said, it isn’t truly random as it only uses letters and numbers

What you are showing me is called an UUID

You don’t really have a random string. Though a UUID for keys is great!
But for a truly random string, utf8 has WAYYYY MORE CHARACTERS than a GUID.

That is technically three lines. I’m assuming that is a unicode random generator.

This seems very useful for procedural tags and such, I’ll probably be using this for future projects.

1 Like

i have shortened it to one :exploding_head::exploding_head::exploding_head:

return function() game:GetService(“HttpService”):GenerateGUID() end

Gotta admit - for a first post, pretty good post construction. Also, this will be very useful for generating secret user Keys or something like that! Well done and keep up the good work.

2 Likes

supposed to be GenerateGUID(false) if used to a important key so its not in {}

But why would you not want the brackets?

bc u wanted string not string in a table, but u can unpack it

The brackets are part of the string, it’s like “{hkjlsf343-hJKFH67OI}”

u waste few byte for extra length (~2-4b), optimization and effiency is 1st (my opinion)

That makes more sense. But why not use string.pack?

In that case, why don’t you do just a random Unicode character or an internal ID system to get random generator? why don’t you do tostring(math.random())

back to you,its your opinion to choose which should u pick

I shortened it down to one

local http, str = game:GetService("HttpService"), http:GenerateGUID()

JK lol. thought it was funny maybe its not. idek if it will work. But all in all. This module looks cool and looked fun to make

1 Like