# Generate random code

**URL:** https://community.thunkable.com/t/generate-random-code/428208
**Category:** Questions about Thunkable X
**Created:** [January 26, 2020, 1:14pm UTC](https://community.thunkable.com/t/generate-random-code/428208 "2020-01-26T13:14:34Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Fernando\_Matos](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/fernando_matos/32/30641_2.png) [@Fernando\_Matos](https://community.thunkable.com/u/Fernando_Matos)
#### Post date: [January 26, 2020, 1:14pm UTC](https://community.thunkable.com/t/generate-random-code/428208/1 "2020-01-26T13:14:34Z")

</div>

hello everyone I would like to create a random id with numbers and letters with a number of different characters! does anyone know how?

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [January 26, 2020, 2:13pm UTC](https://community.thunkable.com/t/generate-random-code/428208/2 "2020-01-26T14:13:48Z")

</div>

I am working this. i’ll have an answer shortly! I will create and share a demo app

DONE!

[https://x.thunkable.com/copy/accd04e351511318a6cc4b9820e5713b](https://x.thunkable.com/copy/accd04e351511318a6cc4b9820e5713b)

i am using the website [Random.org](http://Random.org) ([RANDOM.ORG - String Generator](https://www.random.org/strings/)) - so that’s one holdup but…

 ![Screen Shot 2020-01-26 at 9.16.32 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/1/51c355ec384e6ec00dd69bff7f7f1bc2f1865cf1.png)

they also offer a free and paid API for app/website developers

> **[API Dashboard](https://api.random.org/dashboard)**

---

<div class="post-metadata">

### Author: ![eoinparkinson](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/eoinparkinson/32/143769_2.png) [@eoinparkinson](https://community.thunkable.com/u/eoinparkinson)
#### Post date: [January 26, 2020, 8:00pm UTC](https://community.thunkable.com/t/generate-random-code/428208/3 "2020-01-26T20:00:06Z")

</div>

For numbers you can use the random integer between.

For a six digit number set the minimum number to 100000 and the largest number to 999999.

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [January 26, 2020, 8:09pm UTC](https://community.thunkable.com/t/generate-random-code/428208/4 "2020-01-26T20:09:35Z")

</div>

I had started with that, however, @Fernando_Matos asked for the addition of letters along with the numbers. This creates a much much higher availability of unique identifiers.

Either way, unless you are getting to 1,000,000 users, you shouldn’t have to worry if you just use the integer generator. Also, either way, if this is being implemented there should be a test to verify that the assigned unique identifier is not already in use. [Random.org](http://Random.org) could be used to create a huge random non-repeating string list separated by commas which could be uploaded into your user database. Then each time a user signs up the app could get 1 and delete it from the list. That way you can ensure no 2 users get the same ‘random’ ID on accident.

---

<div class="post-metadata">

### Author: ![Fernando\_Matos](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/fernando_matos/32/30641_2.png) [@Fernando\_Matos](https://community.thunkable.com/u/Fernando_Matos)
#### Post date: [January 26, 2020, 10:36pm UTC](https://community.thunkable.com/t/generate-random-code/428208/5 "2020-01-26T22:36:09Z")

</div>

thanks for the help, it looks interesting. but I would like to generate the codes with lowercase letters, numbers and special characters. and also with the number of digits the user prefers!

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [January 26, 2020, 10:47pm UTC](https://community.thunkable.com/t/generate-random-code/428208/6 "2020-01-26T22:47:06Z")

</div>

This explains how to generate a random string of characters:

> **[Program to generate random alphabets - GeeksforGeeks](https://www.geeksforgeeks.org/program-generate-random-alphabets/)**
>
> Prerequisite : rand() and srand() Given all alphabets in a character array, print a string of random characters of given size. We will use rand()… Read More »

---

<div class="post-metadata">

### Author: ![eoinparkinson](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/eoinparkinson/32/143769_2.png) [@eoinparkinson](https://community.thunkable.com/u/eoinparkinson)
#### Post date: [January 26, 2020, 10:49pm UTC](https://community.thunkable.com/t/generate-random-code/428208/7 "2020-01-26T22:49:38Z")

</div>

I misread the original question!

---

<div class="post-metadata">

### Author: ![eoinparkinson](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/eoinparkinson/32/143769_2.png) [@eoinparkinson](https://community.thunkable.com/u/eoinparkinson)
#### Post date: [January 26, 2020, 10:51pm UTC](https://community.thunkable.com/t/generate-random-code/428208/8 "2020-01-26T22:51:21Z")

</div>

You could make a list, each item in list is either a number from 0 to 9, a letter from a to z, and a special character. Make sense? Then you just pick a random item from list for the amount of characters the user selected.

This might work?

(edit)

Like this:

[0,1,2,3,4,5,6,7,8,9,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,@,#,£,\_,&,-,+,(,),/,\*,",’,:,;,!,?,~,$]

---

<div class="post-metadata">

### Author: ![Fernando\_Matos](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/fernando_matos/32/30641_2.png) [@Fernando\_Matos](https://community.thunkable.com/u/Fernando_Matos)
#### Post date: [January 26, 2020, 11:07pm UTC](https://community.thunkable.com/t/generate-random-code/428208/9 "2020-01-26T23:07:38Z")

</div>

I tried this way but I couldn’t make it work. I found an api that may help with my problem. I will test it in the next few days and will share the result.

---

<div class="post-metadata">

### Author: ![eoinparkinson](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/eoinparkinson/32/143769_2.png) [@eoinparkinson](https://community.thunkable.com/u/eoinparkinson)
#### Post date: [January 26, 2020, 11:11pm UTC](https://community.thunkable.com/t/generate-random-code/428208/10 "2020-01-26T23:11:37Z")

</div>

[https://x.thunkable.com/copy/11d7d22452ec736db948739e9d8ca86e](https://x.thunkable.com/copy/11d7d22452ec736db948739e9d8ca86e)

Seems to work fine for me?

Use input box to select amount of characters, then click button.

🙂

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [January 27, 2020, 2:21am UTC](https://community.thunkable.com/t/generate-random-code/428208/11 "2020-01-27T02:21:21Z")

</div>

Here you go! I think this is exactly what you asked for in the first place @Fernando_Matos

[https://x.thunkable.com/copy/64a8eae058a1b4b49b068caffed26479](https://x.thunkable.com/copy/64a8eae058a1b4b49b068caffed26479)

 ![Screen Shot 2020-01-26 at 9.09.24 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/8/f8bd545eb5bdd7e47ef770e04559028f140cbcc4.png) ![Screen Shot 2020-01-26 at 9.09.15 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/a/9a7e33cb43527e47d9b18b0e8acc783aa4ebe330.png)

---

<div class="post-metadata">

### Author: ![Fernando\_Matos](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/fernando_matos/32/30641_2.png) [@Fernando\_Matos](https://community.thunkable.com/u/Fernando_Matos)
#### Post date: [January 27, 2020, 5:57am UTC](https://community.thunkable.com/t/generate-random-code/428208/12 "2020-01-27T05:57:35Z")

</div>

Hello. thank you yes that’s right i’m going to put these blocks in my project and see if it works. a question. is it preferable to use an API or create this block scheme? thank you all

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [January 27, 2020, 6:07am UTC](https://community.thunkable.com/t/generate-random-code/428208/13 "2020-01-27T06:07:22Z")

</div>

I think it just depends on what you want to do. if you have an api to use, that’s great. you’ just always need an internet connection and are at the mercy of the api providers server limits/uptime/etc. if you create the string natively, you don’t have to worry about anything as far as I know (with my limited knowledge).

I hope it works for you! If so, please click the solve button!

---

<div class="post-metadata">

### Author: ![Fernando\_Matos](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/fernando_matos/32/30641_2.png) [@Fernando\_Matos](https://community.thunkable.com/u/Fernando_Matos)
#### Post date: [January 27, 2020, 1:02pm UTC](https://community.thunkable.com/t/generate-random-code/428208/14 "2020-01-27T13:02:52Z")

</div>

hello I replicated your blocks but the c special characters are not working

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [January 27, 2020, 1:27pm UTC](https://community.thunkable.com/t/generate-random-code/428208/15 "2020-01-27T13:27:16Z")

</div>

Did they combo work when you remixed my app?

---

<div class="post-metadata">

### Author: ![Fernando\_Matos](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/fernando_matos/32/30641_2.png) [@Fernando\_Matos](https://community.thunkable.com/u/Fernando_Matos)
#### Post date: [January 27, 2020, 1:29pm UTC](https://community.thunkable.com/t/generate-random-code/428208/16 "2020-01-27T13:29:26Z")

</div>

yes

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [January 27, 2020, 2:32pm UTC](https://community.thunkable.com/t/generate-random-code/428208/17 "2020-01-27T14:32:43Z")

</div>

can you post a picture of your blocks or a share link? I could check this out sometime

---

<div class="post-metadata">

### Author: ![Fernando\_Matos](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/fernando_matos/32/30641_2.png) [@Fernando\_Matos](https://community.thunkable.com/u/Fernando_Matos)
#### Post date: [January 27, 2020, 2:43pm UTC](https://community.thunkable.com/t/generate-random-code/428208/18 "2020-01-27T14:43:29Z")

</div>

![Sem Título](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/4/440928119503c25fbf6a8c46f6e60ac032f6beb1.png)

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [January 27, 2020, 3:11pm UTC](https://community.thunkable.com/t/generate-random-code/428208/19 "2020-01-27T15:11:21Z")

</div>

try using this block  
 ![Screen Shot 2020-01-27 at 9.59.54 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/9/c9d9233f981b29d70e6e26ca9d42c64c679e13b3.png)

you will likely need to do this if you created the list with a text block and commas

---

<div class="post-metadata">

### Author: ![Fernando\_Matos](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/fernando_matos/32/30641_2.png) [@Fernando\_Matos](https://community.thunkable.com/u/Fernando_Matos)
#### Post date: [January 27, 2020, 3:27pm UTC](https://community.thunkable.com/t/generate-random-code/428208/20 "2020-01-27T15:27:40Z")

</div>

the same

[Next page](https://community.thunkable.com/t/generate-random-code/428208.md?page=2)
