Advertisement
Guest User

Untitled

a guest
Feb 6th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. import java.awt.AlphaComposite;
  2. import java.awt.Color;
  3. import java.io.BufferedWriter;
  4. import java.io.FileOutputStream;
  5. import java.io.FileWriter;
  6. import java.io.IOException;
  7. import java.io.OutputStreamWriter;
  8. import java.util.Random;
  9. import java.util.Scanner;
  10. import javax.swing.JFrame;
  11.  
  12.  
  13. public class one {
  14.  
  15. public static void main(String[] args) throws IOException {
  16. //JFrame window = new Window();
  17. Window classWindow = new Window();
  18. classWindow.WindowOne();
  19.  
  20. //safe(classWindow.WindowOne()[0], classWindow.WindowOne()[1], classWindow.WindowOne()[2]);
  21.  
  22.  
  23. }
  24.  
  25.  
  26. public static String password(int passwordLength) {
  27. final String alphabet = "0123456789ABCDEFGHIJKLNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  28. StringBuilder builder = new StringBuilder();
  29. Random random = new Random();
  30. while(builder.length() < passwordLength) {
  31. int index = (int) (random.nextFloat() * alphabet.length());
  32. builder.append(alphabet.charAt(index));
  33. }
  34. String password = builder.toString();
  35. //System.out.println("Password: " + password);
  36. return password;
  37. }
  38.  
  39.  
  40.  
  41. public static void safe(String password, String Plattform, String Username ) throws IOException {
  42. BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("C:/Users/tebbe/Desktop/PW/Passwords.txt", true)));
  43. out.newLine();
  44. out.write(Plattform + " : ");
  45. out.newLine();
  46. out.write("Username : " + Username);
  47. out.newLine();
  48. out.write("Passwort : " + password);
  49. out.close();
  50. System.out.println("Passwort fΓΌr " + Plattform + " : " + password + " gespeichert!");
  51. }
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement