https://kotlinlang.org logo
#getting-started
Title
# getting-started
a

Ayfri

09/03/2021, 7:33 PM
Hi, do you have any good idea on how to generate secure random IDs ? For a project I need to have IDs for objects, the first digits will be the actual timestamp but then I need at least 5 numbers that should never be the same even in the same millisecond I don't want a super-secure thing, it's just for a personal project with my friends but at least an interesting and important tech to use in development like uuids (so it could be useful for me for future jobs I guess).
d

Dariusz Kuc

09/03/2021, 7:47 PM
if you are on JVM then just use Java
SecureRandom
-> https://github.com/Kotlin/KEEP/issues/184
a

Ayfri

09/03/2021, 7:54 PM
it's for a #compose app that will also be for web and mobile
h

hfhbd

09/03/2021, 10:12 PM
Alternative use an UUID
☝️ 3
d

Dariusz Kuc

09/03/2021, 11:32 PM
I don't think UUID is "secure random"
g

GUIGAL Allan

09/04/2021, 2:08 AM
UUIDs are using secure random, they’re a strong option under the JVM for unique IDs
👍 4
t

Tobias Suchalla

09/04/2021, 12:59 PM
You may also look into Twitter's (deprecated) Snowflake IDs, although they are not exactly random.
2 Views