Advertisement
tamaro_skaljic

PasswordGenerator

Sep 10th, 2019 (edited)
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class PasswordGenerator {
  4.     public static void main(String[] args) {
  5.         byte dez;
  6.        
  7.         String password = "";
  8.         boolean valid = false;
  9.         for (int i = 1; i <= 10; i += (1)) {
  10.             while (valid == false) {
  11.                 dez = (byte) ((Math.random() * 127) + 0);
  12.                 if (dez > 32 && dez < 127) {
  13.                     password = password + (char)(dez);
  14.                     valid = true;
  15.                 }
  16.             }
  17.             valid = false;
  18.         }
  19.         System.out.println(password);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement