Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


[JAVA][SNIPPET]Random Number Generation - HackCommunity Exclusive filter_list
Author
Message
RE: [JAVA][SNIPPET]Random Number Generation - HackCommunity Exclusive #9
Code:
import java.util.*;

public class PasswordGenerator
{
    private static Random noise = new Random();
    
    
    public static char randomLetter()
    {
      int x;
      x = noise.nextInt(25)+ 97;
      char c = (char) x;
      return c;
    }
    
   public static StringBuilder makePassword(int y)
   {
       StringBuilder passBuilder = new StringBuilder(32);
       while (y > 0)
       {
           passBuilder.append(randomLetter());
           y--;
       }
       return passBuilder;
   }
  
   public static void printPassword()
   {
        int i = 1;
        do
        {
             System.out.println(makePassword(8));
             i++;
        }
        while( i <= 10);
            

        
   }
  
public static StringBuilder makeBetterPassword(int y)
   {
       StringBuilder password = new StringBuilder(32);
      for (int x = y -1; x > 0; x--)
      {
           password.append(randomLetter());
      }
      password.append(noise.nextInt(7)+ 2);
      if (noise.nextBoolean() == true)
      {
          password.reverse();
      }
        return password;
   }
    public static void makeEvenBetterPassword(int y)
   {
       StringBuilder betterPassword = new StringBuilder(makeBetterPassword(y));

       char uScore = '_';
       for (int i = y - 1; i > 0; i--)
       {
          
           if(betterPassword.charAt(i) == 'l')
           {
               betterPassword.setCharAt(i, uScore);
           }  
           if(betterPassword.charAt(i) == 'o')
           {
               betterPassword.setCharAt(i, uScore);
           }        
          
       }
       System.out.println(betterPassword);
    }
    
}

Just pulled this out of a class file a did a while back. It's based on the same principles as your post, also before anyone gets a chance; I know the passwords are weak - it's more of a demo.

Sorry for a possible thread hijack, just didn't think it was worth it's own post and it relates to OP Smile

AP1

Reply





Messages In This Thread



Users browsing this thread: 1 Guest(s)