Hi, today will be an easy one. Create a procedure (function) that generate randomized password.
Input will contain
(Num) Length of result
Exclude character (String) // if it is empty nothing is excluded.
CanBeRepeated (Boolean) // if true character can be repeated, otherwise not.
The generator by default contain (a-z) both upper and down case, 0-9, !@#$%^&*()
If length of result is less than 1, return “error”
Edit: In post 5 @Mohamed_Tamer found if can be repeated is false, it will crash if length is greater than 77. You should set condition to return “error” as well.
BTW, there must add a note for the max length.Because for example when i try using my procedure with length 50 and CanBeRepeated set to false the app crashes?But it works successfuly for 1000 character if CanBeRepeated equals true.
You didn’t understand me.I mean that:
If we set CanBeRepeated to false
And set the pass length to any number more then the number of characters we have which are those:
The app will crash because the meaning of that i set length to 80 and set CanBeRepeated to false.So the password will contain 80 different charectars Although there aren’t except 77 letter only so the app will go in an infinite loop which will cause it to crash.you can try using your procedure by setting its length to 80 and CanBeRepeated to false.
So there must be limit for the password length.
EDIT: i realized that they are 77 sorry
I didn’t understand this.You mean that if we have excludeCharacter like this : “String”
So the password can’t contain S and t and r and i and n and g ! That means that it can’t be like that : hSjig6t)rfdn ?
Or, the password can’t contain the word String with all of it’s letter in a consecutive order.That means that it can’t be like that String89u798{ ?
Here is my procedure.it has no errors because it get the limit by subtracting the length of the letters that will be excluded.3 blocks can be reduced by setting the limit to a static number which is 77 ( if you want i can remove them ).But the app will crash for the large numbers.That doesn’t happen in this procedure.:
But unfortunately,It has 51 blocks