i noticed something that surprised me very much. I have programmed a password generator via Uipath-Studio, which generates a password according to certain criteria (at least 10 characters, max 20 characters, which contains at least one lowercase letter, one uppercase letter and at least one special character or number.
I did it in such a way that at the beginning there was a request as to whether you would like to reassign a password manually or to generate a new one. Everything has been done so far and is running correctly through the studio. To check the generated passwords, I put the sequence in an endless loop to see what the generated passwords look like. The following is output to me when I start / run the project via the studio:
Alright so far. The password is then stored in a text file.
Then i published the project and ran it through the robot. Strangely, the passwords stored in the text file look like this:
and so on…
As you can see, the characters from the 3rd or 4th digit are always the same. I wonder why the robot works differently or outputs something different than when i open the process via the studio? This is not a coincidence and not normal
Did you have such a case or do you know the reason for the different spending behavior?
Thanks in advance and have a nice WE
I’m assuming you’re using new Random() to pick a random value from somehere?
Let’s preface this answer by saying that it’s usually not the best idea to build a password generator that relies on unsecure random fuctions, you should use this:
One possible reason for you repeating passwords might be, that a lot of random functions simply use the current time as the seed, which means that if you execute the function several times within a millisecond, you’ll get the same result.
As the robot is executing the compiled workflow it’s much faster than your studio execution.
If this is actually the problem (which I’m not 100% sure of) you could either try using the RandomNumberGenerator or use Random.next if you not already do.
For a more detailled answer I’d need to see your code.
If this has helped you, please mark this answer as the solution.
many thanks for your extensive answer and help.
I am using the Random().next function. The code, where the signs repeat, looks like that:
One of my lists contains 89 signs. If the robot collected the first 3 signs into the Final-Collection, it continues with the do-while section, until the list contains x values. Is the code not logically correct?
When we are assuming how you said, it is a time problem, can we code a time interruption for every loop, maybe 1 ms?
But you’re always creating a new Random object which resets the seed.
Try creating the Random object outside of your loop
rand = new Random()
and then use .Next() in your loop
randomInt = rand.Next(89)
Here’s a simple example on how to do it:
Main.xaml (6.1 KB)
Oh man, you are right. I don’t know how could i not notice that.
Thank you very much for your help. Now it works like a charm. ;))
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.