#SecureRandom is very slow when executed in remote server

1 messages · Page 1 of 1 (latest)

hearty nebula
#

Hello

In the context of building an app to generate 4 digits random code as OTP code, I face something strange: when I try on my local dev environment, the generation is fast, but on server it takes around 15 mins! Any help please?

terse ruinBOT
#

<@&987246964494204979> please have a look, thanks.

terse ruinBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

fiery dock
#

you might be falling victim to not collecting entropy quickly enough

#

we actually had this problem where I work and had to modify the random source

hearty nebula
fiery dock
#

check out the SO post

hearty nebula
fiery dock
#

yeah

hearty nebula
#

I don't get it, what should I do exactly ?

#

If you want a PRNG, do something like this:

SecureRandom.getInstance("SHA1PRNG");

fiery dock
#

yeap try starting with this

hearty nebula
#

The problem is: my team doesn't agree on this approach :/ I mean the use of SecureRandom

#

especially now after having this issue

fiery dock
#

did you try the solution

#

and see if it improves the situation

hearty nebula
#

I can but I have no issue in my local env

#

I want to test on server, but I'm afraid this will not solve the issue

#

btw I think the problem is maybe cause of linux

#

What do you think?

fiery dock
#

the source of the problem is mentioned in many, many replies to that SO, which is the slow default entropy collection on linux machines

#

you don't have the problem locally because you have a different entropy storage, different sources of it and potentially a different OS with different collection algorithms

#

I recommend starting with the approved answer

hearty nebula
#

Got it! thank you @fiery dock