Skip to content

Commit

Permalink
Merge pull request #1 from giorgoslivas/Version2
Browse files Browse the repository at this point in the history
V2.0
  • Loading branch information
georgelivas authored Jan 24, 2017
2 parents dbfe8b7 + d6bf930 commit 0cac2ce
Show file tree
Hide file tree
Showing 38 changed files with 628 additions and 527 deletions.
798 changes: 363 additions & 435 deletions .idea/workspace.xml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions out/production/codeGenerator/20170122_234512
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LRX$M5"!2b14hg#d
im3$#5B9!OrHGh"0
Binary file not shown.
Binary file modified out/production/codeGenerator/com/glivas/passGen/Main.class
Binary file not shown.
Binary file modified out/production/codeGenerator/com/glivas/passGen/PassGen.class
Binary file not shown.
Binary file not shown.
Binary file modified out/production/codeGenerator/com/glivas/passGen/UserInt.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
42 changes: 42 additions & 0 deletions src/Generated Codes
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
_____ __ _____
/ ___/__ ___/ /__ / ___/__ ___
/ /__/ _ \/ _ / -_) (_ / -_) _ \
\___/\___/\_,_/\__/\___/\__/_//_/

M8!5bjC$"QPd#34a
1fUW#S$!Dc8"0q3j
h$kPJF42G#bd3!"8
Z#1"Vvg!2n$0IsM8
R$i3K#"Qe16W5!nw
7zDn#QM03G$1!av"
L!48d"#7S6$TezAc
"om#Z95YPg1$!2Fi
$#nqu8Nm6"07A!CB
!91$8"GHo#Lly2Cq
Bk"N$hdI6n4!3H#0
!9MLe#$iI1Z8q4b"
!"jwH6NXL1$va49#
Zqb256r"L!#3$JOg
!j8D$Bw"Ti3#7tV9
"maGr$64sL5#9!WQ
M60$8U!N"dgP9#hs
!#V"Tp$Lm12Sb4q9
"486wOJ$Xv2hi#!L
k$5G#C2cx3D!"4Hd
G8$Q4qnpXg"#2E7!
bf!p#B$SFa2P15"7
z1J4$Q#2!xeTkP"7
#3X"UlD5K$o8!2sm
!WO#Q640sAyt$"p5
mS"x$cJK1y9#T!65
$6Zg7Xv1"4!JGr#k
4t3n!m#6E"1WT$xQ
!bhe"N#D$72Tt30I
#J81wAl7vk5L$P!"
!k50#$SGt"yi98YK
nS97e!#P$2"5DQdt
M6x"2$zh9JSH7#l!
#12rg$T!4mUe"P5I


Created by George Livas
Binary file added src/com/glivas/passGen/Holder.class
Binary file not shown.
67 changes: 67 additions & 0 deletions src/com/glivas/passGen/Holder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.glivas.passGen;

import java.io.*;

public class Holder {

static String[] keyHolder;
static int index = 0;

public static void genCodes (int numOfCodes) {
keyHolder = new String[numOfCodes];
for (int i = 0; i < keyHolder.length; i++) {
keyHolder[i] = PassGen.generateCode(1);
}
}

public static void printCodes (int codesPerLine){

for (int i = 0; i < codesPerLine; i++) {
System.out.print((char)27
+ "[31;m"
+ "| "
+ (char)27
+ "[36;m"
+ keyHolder[index]
+ (char)27
+ "[31;m"
+ " |"
);
index++;
}
}

public static void createDocument () {
BufferedWriter writer = null;
try {
String fileName = "Generated Codes";
File codeFile = new File(fileName);

System.out.print((char)27 + "[32;m" + "The file is located at: ");
System.out.println((char)27 + "[31;m" + codeFile.getCanonicalPath());

writer = new BufferedWriter(new FileWriter(codeFile));
writer.write(
" _____ __ _____ \n" +
" / ___/__ ___/ /__ / ___/__ ___ \n" +
"/ /__/ _ \\/ _ / -_) (_ / -_) _ \\\n" +
"\\___/\\___/\\_,_/\\__/\\___/\\__/_//_/\n" +
" \n");

for (int i = 0; i < keyHolder.length; i++) {
writer.write(keyHolder[i]);
writer.write("\n");
}
writer.write("\n\nCreated by George Livas");

} catch (Exception e) {
e.printStackTrace();
} finally {
try {

writer.close();
} catch (Exception e) {
}
}
}
}
Binary file added src/com/glivas/passGen/Main.class
Binary file not shown.
7 changes: 6 additions & 1 deletion src/com/glivas/passGen/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
public class Main {

public static void main(String[] args) {
UserInt.loadTUI(100);
StartUp.CodeGen();

}
}

//To run in console:
//compile: javac com/glivas/passGen/*.java
//run main: java com.glivas.passGen.Main
Binary file added src/com/glivas/passGen/PassGen.class
Binary file not shown.
8 changes: 4 additions & 4 deletions src/com/glivas/passGen/PassGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ public String getPassword() {
return this.password;
}

public static void generateCode (int numOfPasswords) {
for (int i = 0; i < numOfPasswords; i++) {

System.out.println((char)27 + "[36;m" + new PassGen(4, 4, 4, 4).getPassword());
public static String generateCode (int numOfPasswords) {
for (int i = 0; i < numOfPasswords-1; i++) {
return new PassGen(4, 4, 4, 4).getPassword();
}
return new PassGen(4, 4, 4, 4).getPassword();
}
}
Binary file added src/com/glivas/passGen/PrintLogo.class
Binary file not shown.
21 changes: 10 additions & 11 deletions src/com/glivas/passGen/PrintLogo.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ public static void codeGen (int times) {
for (int i = 0; i < times; i++) {
System.out.println((char) 27 + "[32;m");
System.out.println(
" .d8888b. 888 .d8888b. \n" +
"d88P Y88b 888 d88P Y88b \n" +
"888 888 888 888 888 \n" +
"888 .d88b. .d88888 .d88b. 888 .d88b. 88888b. \n" +
"888 d88\"\"88b d88\" 888 d8P Y8b 888 88888 d8P Y8b 888 \"88b \n" +
"888 888 888 888 888 888 88888888 888 888 88888888 888 888 \n" +
"Y88b d88P Y88..88P Y88b 888 Y8b. Y88b d88P Y8b. 888 888 \n" +
" \"Y8888P\" \"Y88P\" \"Y88888 \"Y8888 \"Y8888P88 \"Y8888 888 888 \n" +
" \n" +
" \n" +
" \n");
"\t .d8888b. 888 .d8888b. \n" +
"\td88P Y88b 888 d88P Y88b \n" +
"\t888 888 888 888 888 \n" +
"\t888 .d88b. .d88888 .d88b. 888 .d88b. 88888b. \n" +
"\t888 d88\"\"88b d88\" 888 d8P Y8b 888 88888 d8P Y8b 888 \"88b \n" +
"\t888 888 888 888 888 888 88888888 888 888 88888888 888 888 \n" +
"\tY88b d88P Y88..88P Y88b 888 Y8b. Y88b d88P Y8b. 888 888 \n" +
"\t \"Y8888P\" \"Y88P\" \"Y88888 \"Y8888 \"Y8888P88 \"Y8888 888 888 \n" +
(char) 27 + "[31;m\t\t Created by George Livas.\n\n"
);
}
}
}
Binary file added src/com/glivas/passGen/SpecialCharRange.class
Binary file not shown.
Binary file added src/com/glivas/passGen/StartUp.class
Binary file not shown.
26 changes: 26 additions & 0 deletions src/com/glivas/passGen/StartUp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.glivas.passGen;

import java.util.Scanner;

public class StartUp {
public static void CodeGen () {
UserInt.clearScreen();
PrintLogo.codeGen(1);

System.out.println((char)27 + "[32;m" + "CodeGen is a code generator which can create codes of 16 characters\n" +
"long and the user haves the ability to store them in a text file (.txt). Each password \n" +
"contains 4 capital letters (A,B,C), 4 lowercase letters (a,b,c), 4 numbers (1,2,3)\n" +
"and 4 special characters (!,@,£) in random order.\n" +
"So the outcome is similar to this: " + (char)27 + "[31;m" + " \"$0GyLs!#fjJ\"7P49\"\n"+ (char)27 + "[32;m" +
"The outcome is unpredictable and the possibility of a code been generated twice is 0,3333333%.\n\n" + (char)27 + "[36;m" +
"1) To start press [enter].\n" +
"2) To exit press [^c]"
);

Scanner sc = new Scanner(System.in);

if (sc.hasNextLine()) {
UserInt.startCodeGen();
}
}
}
Binary file added src/com/glivas/passGen/UserInt.class
Binary file not shown.
115 changes: 108 additions & 7 deletions src/com/glivas/passGen/UserInt.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,123 @@
package com.glivas.passGen;

import java.util.Scanner;

public class UserInt {

public static void clearScreen() {
System.out.print("\033[H\033[2J");
System.out.flush();
for (int i = 0; i < 500; i++) {
System.out.println();
}
System.out.print("\033[H\033[2J");
System.out.flush();
}

public static void startCodeGen () {

clearScreen();

PrintLogo.codeGen(1);
System.out.println();
//System.out.format("%5d", "Insert number of passwords:");
System.out.print((char)27 + "[33;m" + "Insert number of passwords:");

Scanner sc = new Scanner(System.in);
int numOfCodes = sc.nextInt();
clearScreen();
PrintLogo.codeGen(1);


loadTUI(numOfCodes);
}

public static void terminateCodeGen (int numOfPasswords) {

System.out.print("\n"
+ (char)27
+ "[32;m"
+ numOfPasswords
+ " passwords have been generated."
+ (char)27
+ "[33;m"
+ "\n\nDo you want to export them in a file?(.txt) [y/n]: ");
Scanner sc = new Scanner(System.in);
String des = sc.next();

if(des.equals("y")){
clearScreen();
Holder.createDocument();
System.out.println((char)27 + "[36;m" + "\nThanks for dropping by.\nSee you later.\n\n");
System.out.println((char)27 + "[32;m" );
} else if (des.equals("n")) {
System.out.println((char)27 + "[36;m" + "\nThanks for dropping by.\nSee you later.\n\n");
System.out.println((char)27 + "[32;m" );

}


}


public static void loadTUI (int numOfCodes) {
int numOfCols;
int divNumOfPasswords;

if (numOfCodes < 50) {
numOfCols = 1;
int numOfCols = 1;
int divNumOfPasswords = 1;

Holder.genCodes(numOfCodes);

if (numOfCodes < 25 ){
divNumOfPasswords = numOfCodes;
} else if (numOfCodes >= 50 && numOfCodes < 100) {
} else if (numOfCodes >= 25 && numOfCodes <= 50) {
numOfCols = 2;
divNumOfPasswords =numOfCodes/2;
divNumOfPasswords = numOfCodes/2;
} else if (numOfCodes > 50 && numOfCodes <= 75) {
numOfCols = 3;
divNumOfPasswords = numOfCodes/3;
} else if (numOfCodes > 75 && numOfCodes <= 100 || numOfCodes > 100) {
numOfCols = 4;
divNumOfPasswords = numOfCodes/4;
}


if (numOfCols == 1) {
for (int i = 0; i < divNumOfPasswords; i++) {
System.out.println((char)27 + "[31;m" + "|------------------|");
Holder.printCodes(1);
System.out.println();
}
terminateCodeGen(numOfCodes);
}


PassGen.generateCode(100);
if (numOfCols == 2) {
for (int i = 0; i < divNumOfPasswords; i++) {
System.out.println((char)27 + "[31;m" + "|------------------||------------------|");
Holder.printCodes(2);
System.out.println();
}
terminateCodeGen(numOfCodes);
}


if (numOfCols == 3) {
for (int i = 0; i < divNumOfPasswords; i++) {
System.out.println((char) 27 + "[31;m" + "|------------------||------------------||------------------|");
Holder.printCodes(3);
System.out.println();
}
terminateCodeGen(numOfCodes);
}


if (numOfCols == 4) {
for (int i = 0; i < divNumOfPasswords; i++) {
System.out.println((char) 27 + "[31;m" + "|------------------||------------------||------------------||------------------|");
Holder.printCodes(4);
System.out.println();
}
terminateCodeGen(numOfCodes);
}
}
}
Binary file added src/com/glivas/passGen/codegen$1.class
Binary file not shown.
Binary file added src/com/glivas/passGen/codegen.class
Binary file not shown.
41 changes: 0 additions & 41 deletions src/com/glivas/passGen/codegen.form

This file was deleted.

28 changes: 0 additions & 28 deletions src/com/glivas/passGen/codegen.java

This file was deleted.

0 comments on commit 0cac2ce

Please sign in to comment.