Note that there are some explanatory texts on larger screens.

plurals
  1. PORandom password generation
    text
    copied!<p>I have written a code for random password generation.There are a string from where i have to make the password.so i try to categorize the string according to uppercase array , lower case array and digit array. but here comes a problem when.. </p> <pre><code> for(int k=0;k&lt;Length;k++){ if(asc[k]&gt;=65 &amp;&amp; asc[k]&lt;=90){ UpperCase[k]=(char)asc[k]; } else if(asc[k]&gt;=48 &amp;&amp; asc[k]&lt;=57){ Digit[k]=(char)asc[k]; } else { Mixed[k]=(char)asc[k]; } } </code></pre> <p>is executed it counts some space which i don't want.coding looks like ugly sry for my poor coding.i know there is a lot more way to solve it but i want to go through this.here is my code. here is my code </p> <pre><code>import java.util.Random; public class Randompassgeneration { final int MAX_LENGTH = 20; final int MIN_LENGTH = 3; char[] password=new char[25]; int [] asc=new int[18]; char[] UpperCase=new char[25]; char[] Digit=new char[25]; char[] Mixed=new char[25]; public void generate(String allowedCharacters) { int Length=allowedCharacters.length(); for (int i=0;i&lt;Length;i++) { asc[i]=(int)allowedCharacters.charAt(i); } for (int k=0;k&lt;Length;k++) { if (asc[k]&gt;=65 &amp;&amp; asc[k]&lt;=90) { UpperCase[k]=(char)asc[k]; } else if (asc[k]&gt;=48 &amp;&amp; asc[k]&lt;=57) { Digit[k]=(char)asc[k]; } else { Mixed[k]=(char)asc[k]; } } String rp=null; StringBuilder Strbld=new StringBuilder(); Random rnd=new Random(); int ranStrLen=rnd.nextInt(MAX_LENGTH - MIN_LENGTH + 1) + MIN_LENGTH; Strbld.append(UpperCase[rnd.nextInt(UpperCase.length)]); Strbld.append(Digit[rnd.nextInt(Digit.length)]); for (int m=0; m&lt;ranStrLen-2; m++) { Strbld.append(Mixed[rnd.nextInt(Mixed.length)]); } System.out.print(ranStrLen +"-&gt;"+ Strbld.toString()); } public static void main(String[] args) { String allowedCharacters = "weakPasSWorD1234$*"; Randompassgeneration t=new Randompassgeneration(); t.generate(allowedCharacters); } } </code></pre> <p>Any kind of suggestion?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload