From edddfde8a8de65fa8e828337bce67718fd89a91f Mon Sep 17 00:00:00 2001 From: Emma Nora Theuer Date: Wed, 4 Sep 2024 20:20:38 +0200 Subject: [PATCH] Move into correct directory --- pom.xml | 65 ---------------------------- src/main/java/Main.java | 95 ----------------------------------------- src/pom.xml | 65 ---------------------------- 3 files changed, 225 deletions(-) delete mode 100644 pom.xml delete mode 100644 src/main/java/Main.java delete mode 100644 src/pom.xml diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 5f1794a..0000000 --- a/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - 4.0.0 - - com.enatheuer - Passgen - jar - 1.0-SNAPSHOT - Passgen - http://maven.apache.org - - - - info.picocli - picocli - 4.7.4 - - - - - src/main/java - - - org.apache.maven.plugins - maven-jar-plugin - 3.2.0 - - - - true - lib/ - Main - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.4.1 - - - package - - shade - - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - - - - diff --git a/src/main/java/Main.java b/src/main/java/Main.java deleted file mode 100644 index 33e1504..0000000 --- a/src/main/java/Main.java +++ /dev/null @@ -1,95 +0,0 @@ -import java.security.SecureRandom; -import java.io.IOException; -import java.nio.file.Paths; -import java.nio.file.Files; -import java.util.List; -import picocli.CommandLine; -import picocli.CommandLine.Option; - -public class Main implements Runnable { - private static SecureRandom random; - - @Option(names = {"-x", "--xkcd"}, description = "Will generate an xkcd-style password (See xkcd 936)") - private boolean xkcd = false; - - @Option(names = {"-s", "--simple"}, description = "Will generate a password of specified length without special characters") - private boolean simple = false; - - @Option(names = {"-l", "--length"}, description = "Will generate a regular password with the provided amount of characters (or words for XKCD passwords). Defaults to 32.") - private int length = 32; - - @Option(names = {"-h", "--help"}, usageHelp = true, description = "Displays this help message and exits.") - private boolean help; - - private static String generate_simple_password(int count) { - String simpleCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; - String password = ""; - int randomIndex; - char randomChar; - for (int i = 0; i < count; i++) { - randomIndex = random.nextInt(simpleCharacters.length()); - randomChar = simpleCharacters.charAt(randomIndex); - password = password + randomChar; - } - return password; - } - - private static String generate_regular_password(int count) { - String characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*"; - String password = ""; - int randomIndex; - char randomChar; - for (int i = 0; i < count; i++) { - randomIndex = random.nextInt(characters.length()); - randomChar = characters.charAt(randomIndex); - password = password + randomChar; - } - return password; - } - - private static String generate_xkcd_password(int count) { - String password = ""; - try { - List dictionary = Files.readAllLines(Paths.get("/usr/share/dict/words")); - - int randomIndex; - String randomWord; - for (int i = 0; i < count; i++) { - randomIndex = random.nextInt(dictionary.size()); - randomWord = dictionary.get(randomIndex); - password = password + randomWord; - password = password + " "; - } - } catch (IOException e) { - e.printStackTrace(); - System.out.println("An error occured while reading /usr/share/dict/words - Is the file present?"); - System.exit(2); - } - return password; - } - public static void main(String[] args) { - random = new SecureRandom(); - int exitCode = new CommandLine(new Main()).execute(args); - System.exit(exitCode); - } - - @Override - public void run() { - if (xkcd && simple) { - System.out.println("Error: Only use one of xkcd (-x), simple (-s) or regular (-r) at once."); - System.exit(2); - } - if (xkcd) { - System.out.println(generate_xkcd_password(length)); - System.exit(0); - } - else if (simple) { - System.out.println(generate_simple_password(length)); - System.exit(0); - } - else { - System.out.println(generate_regular_password(length)); - System.exit(0); - } - } -} diff --git a/src/pom.xml b/src/pom.xml deleted file mode 100644 index 5f1794a..0000000 --- a/src/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - 4.0.0 - - com.enatheuer - Passgen - jar - 1.0-SNAPSHOT - Passgen - http://maven.apache.org - - - - info.picocli - picocli - 4.7.4 - - - - - src/main/java - - - org.apache.maven.plugins - maven-jar-plugin - 3.2.0 - - - - true - lib/ - Main - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.4.1 - - - package - - shade - - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - - - -