diff --git a/upassword b/upassword index efb0d14..d95aaa5 100755 --- a/upassword +++ b/upassword @@ -4577,13 +4577,9 @@ public class upassword { final String PUNCTUATIONS = "!:;,?."; String seed; // taille minimale de la chaine - if (size < 1) { - size = 3; - } + if (size < 1) size = 1; // S'il y a trop de ponctuations à placer - if (punctuationsNumber > size) { - punctuationsNumber = size; - } + if (punctuationsNumber > size) punctuationsNumber = size; // préparation d'un constructeur de chaîne StringBuilder builder = new StringBuilder(size); String punctuationsUsed = ""; @@ -4614,9 +4610,6 @@ public class upassword { } return builder.toString(); } - public static String generateJk(int size, int punctuationsNumber) { - return generateJk(size, punctuationsNumber, DEFAULT_RAND); - } public PasswordGenerator(int minLen, String[] sections, int[] minCounts, Random rand) { setMinLen(minLen); @@ -4681,6 +4674,12 @@ public class upassword { return generate(minLen, maxLen, sections, minCounts, rand); } + public String generateJk(int size, int punctuationsNumber) { + return generateJk(size, punctuationsNumber, rand); + } + public String generateJk(int size) { + return generateJk(size, 1, rand); + } public String generateJk() { return generateJk(4, 1, rand); } @@ -5011,6 +5010,8 @@ public class upassword { + "\n upassword -f aeskeyfile -d crypted" + "\n upassword --batch" + "\n\nOPTIONS" + + "\n -b, --nb-blocks COUNT" + + "\n Indiquer le nombre de blocs de mots de 4 caractères pour la génération" + "\n -p, --hash-password" + "\n Crypter un mot de passe (option par défaut). Si le mot de passe en clair" + "\n et/ou le salt ne sont pas spécifiés, ils sont choisis au hasard." @@ -5071,6 +5072,7 @@ public class upassword { return; } + int nbBlocks = 4; EAction action = EAction.HASH_PASSWORD; EHashAction hashAction = EHashAction.AUTO; boolean codEtu = false, crypted = false, shell = false; @@ -5079,7 +5081,19 @@ public class upassword { int i = 0, max = args.length; while (i < args.length) { String arg = args[i]; - if (arg.equals("-p") || arg.equals("--hash-password")) { + if ((arg.length() >= 2 && arg.substring(0, 2).equals("-b")) + || arg.equals("--nb-blocks")) { + int shift = 1; + if (arg.equals("-b") || arg.equals("--nb-blocks")) { + if (args.length > i + 1) { + nbBlocks = Integer.parseInt(args[i + 1]); + shift = 2; + } + } else { + nbBlocks = Integer.parseInt(arg.substring(2)); + } + i += shift; + } else if (arg.equals("-p") || arg.equals("--hash-password")) { action = EAction.HASH_PASSWORD; i++; } else if ((arg.length() >= 2 && arg.substring(0, 2).equals("-j")) @@ -5169,7 +5183,7 @@ public class upassword { if (clear == null) { PasswordGenerator pg = new PasswordGenerator(); - clear = pg.generateJk(); + clear = pg.generateJk(nbBlocks); } String newCryptSalt = null;