Generate Random Codes

Someone could help? I want to generate random codes but have to be one for each person. Its like a code to confirm something, the blocks of image i made with a post i found here, but i want codes like rG5zB JCAaZQ jLD5Eu U23XzG

15|690x376

1 Like

Create a list with the letters from A to Z add again from a to z then the numbers from 0 to 9. In addition I would add some symbols @% & $! €, a little as you want.
Create a loop to generate a string of the length you want that generates random numbers and take the corresponding value from the list.
Unfortunately I do not have access to the PC now otherwise I would show you an example but if you have difficulty tomorrow I will be happy to help you with an example.

1 Like

Its make sense do a list of numbers and letters, but i dont know how to use them to generate a code

In the MATH blocks there is the RANDOM function generate a number between 1 and the length of the list and then in the LIST blocks use SELECT ITEM LIST to select the number or letter
:face_with_monocle:

https://docs.kodular.io/blocks/math/#randomint

1 Like

There’s also the pick random item block.

1 Like

This is a good method to create a random string, but the OP said he needs a unique one for each user. Is that right?
In that case, you will have to check the generated code against an online database. Or if you don’t want to use online services, you can generate the code from another unique information, like email address, phone number, IMEI, etc. or a combination of any of those.

3 Likes


It’s Not Working properly, I checked 3 checkboxes But Some time Number Checkbox can’t Generate. only 1 and 2 (Small And Capital) Checked Working.

Do you need an extension for generating a random passoword?
If yes then PM me else ignore this message.

1 Like

I guess, that can be done with the help of a few blocks too! So, instead of creating an extension for it, why not help the user by showing, plus explaining to him/her how to do that with blocks? This way, you’ll be helping in promoting his/her resourcefulness and critical thinking. :slightly_smiling_face:

Motto of KodeJam :stuck_out_tongue:

4 Likes

Thank you.
I shall try what you have said.

1 Like

You can use an additional web service, or an API:
https://www.uuidgenerator.net/

UUID is a universally unique identifier that is generated using a timestamp and the MAC address of the computer on which it was generated according to that service.

By this way, you don’t need to check if it is already on database. Just fetch data from that API.

1 Like