Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Kikismedia's avatar

how to generate random number for users

good day every one I would like to ask for some help, I want to generate a random 10 digit account number to all my users , this random number generated should be send to users after they have successfully completed there registration and after that users should be able to use this number generated to login into there account

if you can assist me with the code and guidelines I will so much appreciate

0 likes
6 replies
Kikismedia's avatar

what's do you recommend that is secured

1 like
sr57's avatar

It depends how parano you are, but 10 random numbers are secure for many app.

1 like
Tray2's avatar

Too easy to brute force.

I would go for at least 32 characters mixing both digits and numbers.

md5: b5f51c5c18456ba2e5505e26a1d2ff70

Or even a 40 character one

sha1: 00615B59E3E336819C027B5092EE7E3482F4BE7B

or

uuid: 8a171216-518e-11eb-ae93-0242ac130002

newbie360's avatar
md5($user->id . $user->created_at)

or ?

$appHiddenKey = 'Ea5eX8';

md5($appHiddenKey . $user->id . $user->created_at)

Please or to participate in this conversation.