I have the following code for generating random passwords:
When I call the function RandomPassword it gives me StringIndexOutOfBoundsExceptionCode:int RandomNumber(int Start, int End) { return (int)(Start + Math.random() * (End - Start)); } String RandomPassword(String passwordSeed, int Length) { int i; String s; int x; String temp = ""; for(i = 0; i < Length; i++) { x = RandomNumber(0,passwordSeed.length()); s = passwordSeed.substring(x,1); temp += s; } return temp; }
What is the solution ? The index is generated correct (as far as I know). So there must be something else going wrong.





Reply With Quote