Advertisement
Guest User

Untitled

a guest
Jan 8th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 20.17 KB | None | 0 0
  1. package com.passwordDiagnoserAPP;
  2.  
  3. import java.util.Random;
  4.  
  5. public class Password implements Comparable<Password> {
  6.    
  7.     private static Random Random = new Random();
  8.     private String password, strengthIndex;
  9.     private boolean  digit, lowerCaseAlphabetical, upperCaseAlphabetical, specialChar, maybeIllegal, lessThan8, moreThan16;
  10.     private int strengthCounter;
  11.        
  12.     /**
  13.      * Constructors:
  14.      * @param password
  15.      */
  16.     public Password(String password)
  17.     {
  18.         //super();
  19.         this.password = password;
  20.         autoDiagnose();
  21.        
  22.     }
  23.    
  24.     public Password(Object password)
  25.     {
  26.         //super();
  27.         this.password = password.toString();
  28.         autoDiagnose();
  29.        
  30.     }
  31.     public Password(Password password)
  32.     {
  33.         //super();
  34.         this.password = password.getPassword();
  35.         autoDiagnose();
  36.        
  37.     }
  38.    
  39.     /**
  40.      * Getters and password (new) setter:
  41.      * @return
  42.      */
  43.    
  44.     public String getPassword() {
  45.         return password;
  46.     }
  47.  
  48.     public void setPassword(String password) {
  49.         this.password = password;
  50.         autoDiagnose();
  51.     }
  52.    
  53.  
  54.     public String getStrengthIndex() {
  55.         return strengthIndex;
  56.     }
  57.  
  58.     public boolean isDigit() {
  59.         return digit;
  60.     }
  61.  
  62.     public boolean isLowerCaseAlphabetical() {
  63.         return lowerCaseAlphabetical;
  64.     }
  65.  
  66.     public boolean isUpperCaseAlphabetical() {
  67.         return upperCaseAlphabetical;
  68.     }
  69.  
  70.     public boolean isSpecialChar() {
  71.         return specialChar;
  72.     }
  73.  
  74.     public boolean isMaybeIllegal() {
  75.         return maybeIllegal;
  76.     }
  77.    
  78.     public boolean isLessThan8() {
  79.         return lessThan8;
  80.     }
  81.  
  82.     public boolean isMoreThan16() {
  83.         return moreThan16;
  84.     }
  85.     public int getStrengthCounter() {
  86.         return strengthCounter;
  87.     }
  88.  
  89.     /**
  90.      * toString:
  91.      */
  92.     public String toString() {
  93.         return "Password [password=" + password + ", strengthIndex="
  94.                 + strengthIndex + ", digit=" + digit
  95.                 + ", lowerCaseAlphabetical=" + lowerCaseAlphabetical
  96.                 + ", upperCaseAlphabetical=" + upperCaseAlphabetical
  97.                 + ", specialChar=" + specialChar + ", maybeIllegal="
  98.                 + maybeIllegal + ", lessThan8=" + lessThan8 + ", moreThan16="
  99.                 + moreThan16 + ", strengthCounter=" + strengthCounter + "]";
  100.     }
  101.  
  102.  
  103.     /**
  104.      * password auto diagnose:
  105.      */
  106.     public void autoDiagnose(){
  107.         lessThan8 = false;
  108.         moreThan16 = false;
  109.         digit = false;
  110.         lowerCaseAlphabetical = false;
  111.         upperCaseAlphabetical = false;
  112.         specialChar = false;
  113.         maybeIllegal = false;
  114.         strengthCounter = 0;
  115.        
  116.         char currentChar;
  117.        
  118.    
  119.         for (int i = 0; i < password.length(); i++)
  120.         {
  121.             currentChar = password.charAt(i);
  122.             if (Character.isDigit(currentChar))
  123.                 digit = true;
  124.             if (Character.isAlphabetic(currentChar))
  125.                 if (Character.isLowerCase(currentChar))
  126.                     lowerCaseAlphabetical = true;
  127.             if (Character.isAlphabetic(currentChar))
  128.                 if (Character.isUpperCase(currentChar))        
  129.                     upperCaseAlphabetical = true;
  130.             if (Character.getNumericValue(currentChar) == -1)
  131.                 specialChar = true;
  132.             if (!Character.isDefined(currentChar))
  133.                 maybeIllegal = true;
  134.         }
  135.        
  136.        
  137.         //strength counter: 0-extremely weak, 1-very weak, 2-weak, 3-strong, 4-very strong, 5-extremely strong.
  138.         if(password.length() < 8){
  139.             lessThan8 = true;
  140.             strengthCounter--; 
  141.         }
  142.         if(password.length() > 16){
  143.             moreThan16 = true;
  144.             strengthCounter++;
  145.         }
  146.         if(lowerCaseAlphabetical)
  147.             strengthCounter++;
  148.         if(upperCaseAlphabetical)
  149.             strengthCounter++;
  150.         if(digit)
  151.             strengthCounter++;
  152.         if(specialChar)
  153.             strengthCounter++;
  154.        
  155.        
  156.         //very weak:
  157.         if(!digit && lowerCaseAlphabetical && !specialChar && !upperCaseAlphabetical)
  158.             strengthIndex = "@0001";
  159.         if(!digit && !lowerCaseAlphabetical && !specialChar && upperCaseAlphabetical)
  160.             strengthIndex = "@0002";
  161.         if (digit && !lowerCaseAlphabetical && !specialChar && !upperCaseAlphabetical)
  162.             strengthIndex = "@0003";   
  163.         if (!digit && !lowerCaseAlphabetical && specialChar && !upperCaseAlphabetical)
  164.             strengthIndex = "@0004";
  165.        
  166.        
  167.         //weak:
  168.         if (!digit && lowerCaseAlphabetical && !specialChar && upperCaseAlphabetical)
  169.             strengthIndex = "@0012";
  170.         if (digit && lowerCaseAlphabetical && !specialChar && !upperCaseAlphabetical)
  171.             strengthIndex = "@0013";
  172.         if (!digit && lowerCaseAlphabetical && specialChar && !upperCaseAlphabetical)
  173.             strengthIndex = "@0014";
  174.         if (digit && !lowerCaseAlphabetical && !specialChar && upperCaseAlphabetical)
  175.             strengthIndex = "@0023";
  176.         if (!digit && !lowerCaseAlphabetical && specialChar && upperCaseAlphabetical)
  177.             strengthIndex = "@0024";
  178.         if (digit && !lowerCaseAlphabetical && specialChar && !upperCaseAlphabetical)
  179.             strengthIndex = "@0034";
  180.        
  181.        
  182.         //strong:
  183.         if(digit && lowerCaseAlphabetical && !specialChar && upperCaseAlphabetical)
  184.             strengthIndex = "@0123";
  185.         if (!digit && lowerCaseAlphabetical && specialChar && upperCaseAlphabetical)
  186.             strengthIndex = "@0124";
  187.         if (digit && lowerCaseAlphabetical && specialChar && !upperCaseAlphabetical)
  188.             strengthIndex = "@0134";
  189.         if (digit && !lowerCaseAlphabetical && specialChar && upperCaseAlphabetical)
  190.             strengthIndex = "@0234";
  191.        
  192.         //very strong:
  193.         if (digit && lowerCaseAlphabetical && specialChar && upperCaseAlphabetical)
  194.             strengthIndex = "@1234";
  195.     }
  196.     /**
  197.      * equals:
  198.      */
  199.    
  200.     public boolean equals(Object obj)
  201.     {
  202.         if (this == obj) {
  203.             return true;
  204.         }
  205.         if (obj == null) {
  206.             return false;
  207.         }
  208.         if (getClass() != obj.getClass()) {
  209.             return false;
  210.         }
  211.         Password other = (Password) obj;
  212.         if (digit != other.digit) {
  213.             return false;
  214.         }
  215.         if (lessThan8 != other.lessThan8) {
  216.             return false;
  217.         }
  218.         if (lowerCaseAlphabetical != other.lowerCaseAlphabetical) {
  219.             return false;
  220.         }
  221.         if (maybeIllegal != other.maybeIllegal) {
  222.             return false;
  223.         }
  224.         if (moreThan16 != other.moreThan16) {
  225.             return false;
  226.         }
  227.         if (password == null) {
  228.             if (other.password != null) {
  229.                 return false;
  230.             }
  231.         } else if (!password.equals(other.password)) {
  232.             return false;
  233.         }
  234.         if (specialChar != other.specialChar) {
  235.             return false;
  236.         }
  237.         if (strengthCounter != other.strengthCounter) {
  238.             return false;
  239.         }
  240.         if (strengthIndex == null) {
  241.             if (other.strengthIndex != null) {
  242.                 return false;
  243.             }
  244.         } else if (!strengthIndex.equals(other.strengthIndex)) {
  245.             return false;
  246.         }
  247.         if (upperCaseAlphabetical != other.upperCaseAlphabetical) {
  248.             return false;
  249.         }
  250.         return true;
  251.     }
  252.     /**
  253.      * compare passwords or password to String:
  254.      * @param arg0
  255.      * @return
  256.      * Because the main character of passwords is their strength, This method compares password strength.
  257.      */
  258.    
  259.     public int compareTo(Password p)
  260.     {
  261.         return p.strengthCounter - this.strengthCounter;
  262.     }
  263.    
  264.     public int compareTo(String s)
  265.     {
  266.         Password p = new Password(s);
  267.         if(this.strengthCounter > p.strengthCounter)
  268.             return this.strengthCounter - p.strengthCounter;
  269.         if(this.strengthCounter < p.strengthCounter)
  270.             return p.strengthCounter - this.strengthCounter;
  271.         return 0;
  272.     }
  273.    
  274.     /**
  275.      * PasswordImprover:
  276.      * @param wS
  277.      */
  278.    
  279.     public void passwordImprover(int wS)
  280.     {
  281.         StringBuilder passwordSB = new StringBuilder(password);
  282.         int randomNum1, randomNum2;    
  283.         char[] lowerCases = "abcdefghijklmnopqrstuvwxyz".toCharArray();
  284.         char[] upperCases = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
  285.         char[] digits = "0123456789".toCharArray();
  286.         char[] specials = "`~!@#$%^&*()-_=+[]{}|:;'<>.,?/".toCharArray();
  287.         if(wS == 2)
  288.         {
  289.             if("@0001".equals(strengthIndex))
  290.             {
  291.                 randomNum1 = Random.nextInt(2);
  292.                 switch(randomNum1)
  293.                 {
  294.                 /* Here is the main problem!!!
  295.                  * there's a need to fix or change the Switch cases to if(){}
  296.                  *
  297.                  * edit: add break; statment in the end of each case~s.
  298.                  */
  299.                 case 0:
  300.                     for(int i = 0; i < password.length(); i++)
  301.                     {
  302.                         randomNum2 = Random.nextInt(2);
  303.                         if (randomNum2 == 1)
  304.                             passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]); // char choosing need check!!
  305.                        
  306.                     }
  307.                     break;
  308.                 case 1:
  309.                     for(int i = 0; i < password.length(); i++)
  310.                     {
  311.                         randomNum2 = Random.nextInt(2);
  312.                         if (randomNum2 == 1)
  313.                             passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);
  314.                        
  315.                     }
  316.                     break;
  317.                 }
  318.             }
  319.             if("@0002".equals(strengthIndex))
  320.             {
  321.                 randomNum1 = Random.nextInt(2);
  322.                 switch(randomNum1)
  323.                 {
  324.                 case 0:
  325.                     for(int i = 0; i < password.length(); i++)
  326.                     {
  327.                         randomNum2 = Random.nextInt(2);
  328.                         if (randomNum2 == 1)
  329.                             passwordSB.setCharAt(i, lowerCases[Random.nextInt(lowerCases.length)]);         // char choosing need check!!  
  330.                     }
  331.                    
  332.                 case 1:
  333.                     for(int i = 0; i < password.length(); i++)
  334.                     {
  335.                         randomNum2 = Random.nextInt(2);
  336.                         if (randomNum2 == 1)
  337.                             passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);            
  338.                     }
  339.                     break;
  340.                 }
  341.             }
  342.             if("@0003".equals(strengthIndex))
  343.             {
  344.                 randomNum1 = Random.nextInt(2);
  345.                 switch(randomNum1)
  346.                 {
  347.                 case 0:
  348.                     for(int i = 0; i < password.length(); i++)
  349.                     {
  350.                         randomNum2 = Random.nextInt(2);
  351.                         if (randomNum2 == 1)
  352.                             passwordSB.setCharAt(i, lowerCases[Random.nextInt(lowerCases.length)]);         // char choosing need check!!  
  353.                     }
  354.                     break;
  355.                 case 1:
  356.                     for(int i = 0; i < password.length(); i++)
  357.                     {
  358.                         randomNum2 = Random.nextInt(2);
  359.                         if (randomNum2 == 1)
  360.                             passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]);            
  361.                     }
  362.                     break;
  363.                 }
  364.             }
  365.             if("@0004".equals(strengthIndex))
  366.             {
  367.                 randomNum1 = Random.nextInt(3);
  368.                 switch(randomNum1)
  369.                 {
  370.                 case 0:
  371.                     for(int i = 0; i < password.length(); i++)
  372.                     {
  373.                         randomNum2 = Random.nextInt(2);
  374.                         if (randomNum2 == 1)
  375.                             passwordSB.setCharAt(i, upperCases[Random.nextInt(lowerCases.length)]);         // char choosing need check!!  
  376.                     }
  377.                     break;
  378.                 case 1:
  379.                     for(int i = 0; i < password.length(); i++)
  380.                     {
  381.                         randomNum2 = Random.nextInt(2);
  382.                         if (randomNum2 == 1)
  383.                             passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]);            
  384.                     }
  385.                     break;
  386.                 case 2:
  387.                     for(int i = 0; i < password.length(); i++)
  388.                     {
  389.                         randomNum2 = Random.nextInt(2);
  390.                         if (randomNum2 == 1)
  391.                             passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);            
  392.                     }
  393.                     break;
  394.                 }
  395.             }
  396.         }
  397.         if(wS == 3)
  398.         {
  399.             if("@0001".equals(strengthIndex))
  400.             {
  401.                 for(int i = 0; i < password.length(); i++)
  402.                 {
  403.                     randomNum2 = Random.nextInt(3);
  404.                     if (randomNum2 == 1)
  405.                         passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]);         // char choosing need check!!
  406.                     if (randomNum2 == 2)
  407.                         passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);        
  408.                 }
  409.             }
  410.             if("@0002".equals(strengthIndex))
  411.             {
  412.                     for(int i = 0; i < password.length(); i++)
  413.                     {
  414.                         randomNum2 = Random.nextInt(3);
  415.                         if (randomNum2 == 1)
  416.                             passwordSB.setCharAt(i, lowerCases[Random.nextInt(lowerCases.length)]);         // char choosing need check!!
  417.                         if (randomNum2 == 2)
  418.                             passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);        
  419.                     }
  420.             }
  421.             if("@0003".equals(strengthIndex))
  422.             {
  423.                 for(int i = 0; i < password.length(); i++)
  424.                 {
  425.                     randomNum2 = Random.nextInt(3);
  426.                     if (randomNum2 == 1)
  427.                         passwordSB.setCharAt(i, lowerCases[Random.nextInt(lowerCases.length)]);         // char choosing need check!!
  428.                     if (randomNum2 == 2)
  429.                         passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]);        
  430.                 }      
  431.             }
  432.             if("@0004".equals(strengthIndex))
  433.             {
  434.                 randomNum1 = Random.nextInt(3);
  435.                 switch(randomNum1)
  436.                 {
  437.                 case 0:
  438.                     for(int i = 0; i < password.length(); i++)
  439.                     {
  440.                         randomNum2 = Random.nextInt(3);
  441.                         if (randomNum2 == 1)
  442.                             passwordSB.setCharAt(i, lowerCases[Random.nextInt(lowerCases.length)]);         // char choosing need check!!
  443.                         if (randomNum2 == 2)
  444.                             passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]);        
  445.                     }
  446.                     break;
  447.                 case 1:
  448.                     for(int i = 0; i < password.length(); i++)
  449.                     {
  450.                         randomNum2 = Random.nextInt(3);
  451.                         if (randomNum2 == 1)
  452.                             passwordSB.setCharAt(i, lowerCases[Random.nextInt(lowerCases.length)]);
  453.                         if (randomNum2 == 2)
  454.                             passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);
  455.                     }
  456.                     break;
  457.                 case 2:
  458.                     for(int i = 0; i < password.length(); i++)
  459.                     {
  460.                         randomNum2 = Random.nextInt(3);
  461.                         if (randomNum2 == 1)
  462.                             passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);
  463.                         if (randomNum2 == 2)
  464.                             passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]);
  465.                     }
  466.                     break;
  467.                 }
  468.             }
  469.             if("@0012".equals(strengthIndex))
  470.             {
  471.                 for(int i = 0; i < password.length(); i++)
  472.                 {
  473.                     randomNum2 = Random.nextInt(2);
  474.                     if (randomNum2 == 1)
  475.                         passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);    
  476.                 }
  477.             }
  478.             if("@0013".equals(strengthIndex))
  479.             {
  480.                 for(int i = 0; i < password.length(); i++)
  481.                 {
  482.                     randomNum2 = Random.nextInt(2);
  483.                     if (randomNum2 == 1)
  484.                         passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]);    
  485.                 }
  486.             }
  487.             if("@0014".equals(strengthIndex))
  488.             {
  489.                 randomNum1 = Random.nextInt(2);
  490.                 switch(randomNum1)
  491.                 {
  492.                 case 0:
  493.                     for(int i = 0; i < password.length(); i++)
  494.                     {
  495.                         randomNum2 = Random.nextInt(2);
  496.                         if (randomNum2 == 1)
  497.                             passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);         // char choosing need check!!          
  498.                     }
  499.                     break;
  500.                 case 1:
  501.                     for(int i = 0; i < password.length(); i++)
  502.                     {
  503.                         randomNum2 = Random.nextInt(2);
  504.                         if (randomNum2 == 1)
  505.                             passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]);    
  506.                     }
  507.                     break;
  508.                 }
  509.             }
  510.             if("@0023".equals(strengthIndex))
  511.             {
  512.                 for(int i = 0; i < password.length(); i++)
  513.                 {
  514.                     randomNum2 = Random.nextInt(2);
  515.                     if (randomNum2 == 1)
  516.                         passwordSB.setCharAt(i, lowerCases[Random.nextInt(lowerCases.length)]);    
  517.                 }
  518.  
  519.                
  520.             }
  521.             if("@0024".equals(strengthIndex))
  522.             {
  523.                 randomNum1 = Random.nextInt(2);
  524.                 switch(randomNum1)
  525.                 {
  526.                 case 0:
  527.                     for(int i = 0; i < password.length(); i++)
  528.                     {
  529.                         randomNum2 = Random.nextInt(2);
  530.                         if (randomNum2 == 1)
  531.                             passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);         // char choosing need check!!          
  532.                     }
  533.                     break;
  534.                 case 1:
  535.                     for(int i = 0; i < password.length(); i++)
  536.                     {
  537.                         randomNum2 = Random.nextInt(2);
  538.                         if (randomNum2 == 1)
  539.                             passwordSB.setCharAt(i, lowerCases[Random.nextInt(lowerCases.length)]);    
  540.                     }
  541.                     break;
  542.                 }
  543.             }
  544.             if("@0034".equals(strengthIndex))
  545.             {
  546.                 randomNum1 = Random.nextInt(2);
  547.                 switch(randomNum1)
  548.                 {
  549.                 case 0:
  550.                     for(int i = 0; i < password.length(); i++)
  551.                     {
  552.                         randomNum2 = Random.nextInt(2);
  553.                         if (randomNum2 == 1)
  554.                             passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]);         // char choosing need check!!          
  555.                     }
  556.                     break;
  557.                 case 1:
  558.                     for(int i = 0; i < password.length(); i++)
  559.                     {
  560.                         randomNum2 = Random.nextInt(2);
  561.                         if (randomNum2 == 1)
  562.                             passwordSB.setCharAt(i, lowerCases[Random.nextInt(lowerCases.length)]);    
  563.                     }
  564.                     break;
  565.                 }
  566.             }
  567.         }
  568.         if(wS == 4)
  569.         {
  570.             if("@0001".equals(strengthIndex))
  571.             {
  572.                 for(int i = 0; i < password.length(); i++)
  573.                     {
  574.                     randomNum2 = Random.nextInt(4);
  575.                     if (randomNum2 == 1)
  576.                         passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]);         // char choosing need check!!
  577.                     if (randomNum2 == 2)
  578.                         passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);
  579.                     if (randomNum2 == 3)
  580.                         passwordSB.setCharAt(i, specials[Random.nextInt(specials.length)]);
  581.                     }
  582.             }
  583.             if("@0002".equals(strengthIndex))
  584.             {
  585.                 for(int i = 0; i < password.length(); i++)
  586.                     {
  587.                     randomNum2 = Random.nextInt(4);
  588.                     if (randomNum2 == 1)
  589.                         passwordSB.setCharAt(i, lowerCases[Random.nextInt(lowerCases.length)]);         // char choosing need check!!
  590.                     if (randomNum2 == 2)
  591.                         passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);
  592.                     if (randomNum2 == 3)
  593.                         passwordSB.setCharAt(i, specials[Random.nextInt(specials.length)]);
  594.                     }
  595.             }
  596.             if("@0003".equals(strengthIndex))
  597.             {
  598.                 for(int i = 0; i < password.length(); i++)
  599.                     {
  600.                     randomNum2 = Random.nextInt(4);
  601.                     if (randomNum2 == 1)
  602.                         passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]);         // char choosing need check!!
  603.                     if (randomNum2 == 2)
  604.                         passwordSB.setCharAt(i, lowerCases[Random.nextInt(lowerCases.length)]);
  605.                     if (randomNum2 == 3)
  606.                         passwordSB.setCharAt(i, specials[Random.nextInt(specials.length)]);
  607.                     }
  608.             }
  609.             if("@0004".equals(strengthIndex))
  610.             {
  611.                 for(int i = 0; i < password.length(); i++)
  612.                     {
  613.                     randomNum2 = Random.nextInt(4);
  614.                     if (randomNum2 == 1)
  615.                         passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]);         // char choosing need check!!
  616.                     if (randomNum2 == 2)
  617.                         passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);
  618.                     if (randomNum2 == 3)
  619.                         passwordSB.setCharAt(i, lowerCases[Random.nextInt(lowerCases.length)]);
  620.                     }
  621.             }
  622.             if("@0012".equals(strengthIndex))
  623.             {
  624.                 for(int i = 0; i < password.length(); i++)
  625.                     {
  626.                     randomNum2 = Random.nextInt(3);
  627.                     if (randomNum2 == 1)
  628.                         passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);
  629.                     if (randomNum2 == 2)
  630.                         passwordSB.setCharAt(i, specials[Random.nextInt(specials.length)]);
  631.                     }
  632.             }
  633.             if("@0013".equals(strengthIndex))
  634.             {
  635.                 for(int i = 0; i < password.length(); i++)
  636.                     {
  637.                     randomNum2 = Random.nextInt(3);
  638.                     if (randomNum2 == 1)
  639.                         passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]);
  640.                     if (randomNum2 == 2)
  641.                         passwordSB.setCharAt(i, specials[Random.nextInt(specials.length)]);
  642.                     }
  643.             }
  644.             if("@0014".equals(strengthIndex))
  645.             {
  646.                 for(int i = 0; i < password.length(); i++)
  647.                     {
  648.                     randomNum2 = Random.nextInt(3);
  649.                     if (randomNum2 == 1)
  650.                         passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);
  651.                     if (randomNum2 == 2)
  652.                         passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]);
  653.                     }
  654.             }
  655.             if("@0023".equals(strengthIndex))
  656.             {
  657.                 for(int i = 0; i < password.length(); i++)
  658.                     {
  659.                     randomNum2 = Random.nextInt(3);
  660.                     if (randomNum2 == 1)
  661.                         passwordSB.setCharAt(i, lowerCases[Random.nextInt(lowerCases.length)]);
  662.                     if (randomNum2 == 2)
  663.                         passwordSB.setCharAt(i, specials[Random.nextInt(specials.length)]);
  664.                     }
  665.             }
  666.             if("@0024".equals(strengthIndex))
  667.             {
  668.                 for(int i = 0; i < password.length(); i++)
  669.                     {
  670.                     randomNum2 = Random.nextInt(3);
  671.                     if (randomNum2 == 1)
  672.                         passwordSB.setCharAt(i, lowerCases[Random.nextInt(lowerCases.length)]);
  673.                     if (randomNum2 == 2)
  674.                         passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);
  675.                     }
  676.             }
  677.             if("@0034".equals(strengthIndex))
  678.             {
  679.                 for(int i = 0; i < password.length(); i++)
  680.                     {
  681.                     randomNum2 = Random.nextInt(3);
  682.                     if (randomNum2 == 1)
  683.                         passwordSB.setCharAt(i, lowerCases[Random.nextInt(lowerCases.length)]);
  684.                     if (randomNum2 == 2)
  685.                         passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]);
  686.                     }
  687.             }
  688.             if("@0123".equals(strengthIndex))
  689.             {
  690.                 for(int i = 0; i < password.length(); i++)
  691.                     {
  692.                     randomNum2 = Random.nextInt(2);
  693.                     if (randomNum2 == 1)
  694.                         passwordSB.setCharAt(i, specials[Random.nextInt(specials.length)]);
  695.                     }
  696.             }
  697.             if("@0124".equals(strengthIndex))
  698.             {
  699.                 for(int i = 0; i < password.length(); i++)
  700.                     {
  701.                     randomNum2 = Random.nextInt(2);
  702.                     if (randomNum2 == 1)
  703.                         passwordSB.setCharAt(i, digits[Random.nextInt(digits.length)]);
  704.                    
  705.                     }
  706.             }
  707.             if("@0134".equals(strengthIndex))
  708.             {
  709.                 for(int i = 0; i < password.length(); i++)
  710.                     {
  711.                     randomNum2 = Random.nextInt(2);
  712.                     if (randomNum2 == 1)
  713.                         passwordSB.setCharAt(i, upperCases[Random.nextInt(upperCases.length)]);
  714.                    
  715.                     }
  716.             }
  717.             if("@0234".equals(strengthIndex))
  718.             {
  719.                 for(int i = 0; i < password.length(); i++)
  720.                     {
  721.                     randomNum2 = Random.nextInt(2);
  722.                     if (randomNum2 == 1)
  723.                         passwordSB.setCharAt(i, lowerCases[Random.nextInt(lowerCases.length)]);
  724.                    
  725.                     }
  726.             }  
  727.         }
  728.         password = passwordSB.toString();
  729.         autoDiagnose();
  730.     }
  731. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement