Tomasz_Kisiel's avatar

Serial key generator - random string with separators.

Is there an easy way to change this:

Str::random(20) // e.g 4O3i7JDV9Em6qSqtL1SH

into this:

4O3i-7JDV-9Em6-qSqt-L1SH

0 likes
4 replies
Tomasz_Kisiel's avatar

uuid is e little bit to long. I need something shorter as a key for new users which want to register. They can register only if they hava a key :D

Snapey's avatar
Snapey
Best Answer
Level 122

probably less work to concatenate 4 x 4 letter strings

$code = sprintf('%s-%s-%s-%s', str::random(4), str::random(4), str::random(4), str::random(4));

Edit: (or 5! You get the idea)

I would probably make it all lowercase also

Please or to participate in this conversation.