From 9838130af6801c0b2f52afdbac20a15db32c20ce Mon Sep 17 00:00:00 2001 From: Jorge <72881403+JSalmon11@users.noreply.github.com> Date: Sat, 24 Jun 2023 13:13:34 +0200 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20Verificaci=C3=B3n=20repeticiones=20?= =?UTF-8?q?caracteres=20(#13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 9 +++++++++ CHANGELOG_es.md | 15 ++++++++++++--- src/Main/App.java | 2 +- src/Utils/GeneratePass.java | 28 +++++++++++++++++++++++++++- 4 files changed, 49 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9df9af9..e5bbe9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # CHANGELOG +## [1.2.0] - 2023-06-24 +### Added +- Added verification not to repeat characters more than 2 times when generating the password. +- Added check not to repeat consecutive identical characters. +- Added verification to not repeat consecutive uppercase characters. +- Added check not to repeat consecutive lowercase characters. +- Added verification not to repeat consecutive numeric characters. + ## [1.1.1] - 2022-03-12 ### Fixed - Fixed button to check available updates. @@ -16,6 +24,7 @@ ## [1.0.0] - 2022-04-08 - Initial release +[1.2.0]: https://github.com/JSalmon11/Generador-de-Contrasenias/compare/1.1.1...1.2.0 [1.1.1]: https://github.com/JSalmon11/Generador-de-Contrasenias/compare/1.1.0...1.1.1 [1.1.0]: https://github.com/JSalmon11/Generador-de-Contrasenias/compare/1.0.0...1.1.0 [1.0.0]: https://github.com/JSalmon11/Generador-de-Contrasenias/compare/b552912c04419d8d2ae5d9fd9bb7f315145f46d8...1.0.0 \ No newline at end of file diff --git a/CHANGELOG_es.md b/CHANGELOG_es.md index 574b874..1b51767 100644 --- a/CHANGELOG_es.md +++ b/CHANGELOG_es.md @@ -1,10 +1,18 @@ # CHANGELOG -## [1.1.1] - 2022-03-12 +## [1.2.0] - 24-06-2023 +### Añadido +- Añadida verificación para no repetir carácteres más de 2 veces al generar la sontraseña. +- Añadida verificación para no repetir dos carácteres iguales seguidos. +- Añadida verificación para no repetir carácteres mayúscula seguidos. +- Añadida verificación para no repetir carácteres minúscula seguidos. +- Añadida verificación para no repetir carácteres numéricos seguidos. + +## [1.1.1] - 12-03-2022 ### Arreglado - Arreglado botón para comprobar actualizaciones. -## [1.1.0] - 2022-04-10 +## [1.1.0] - 10-04-2022 ### Añadido - Añadido botón para comprobar actualizaciones. - Añadido soporte para intenacionalización (es, en, ja). @@ -13,9 +21,10 @@ - Controlado error cuando el campo longitud está vacío. -## [1.0.0] - 2022-04-08 +## [1.0.0] - 08-04-2022 - Lanzamineto inicial. +[1.2.0]: https://github.com/JSalmon11/Generador-de-Contrasenias/compare/1.1.1...1.2.0 [1.1.1]: https://github.com/JSalmon11/Generador-de-Contrasenias/compare/1.1.0...1.1.1 [1.1.0]: https://github.com/JSalmon11/Generador-de-Contrasenias/compare/1.0.0...1.1.0 [1.0.0]: https://github.com/JSalmon11/Generador-de-Contrasenias/compare/b552912c04419d8d2ae5d9fd9bb7f315145f46d8...1.0.0 \ No newline at end of file diff --git a/src/Main/App.java b/src/Main/App.java index d56c853..8263a40 100644 --- a/src/Main/App.java +++ b/src/Main/App.java @@ -30,7 +30,7 @@ * @author Jorge Salmón */ public class App extends Application { - private static String version = "1.1.1"; + private static String version = "1.2.0"; public static final Idioma idioma = new Idioma(System.getProperty("user.language")); public static void main(String[] args) { diff --git a/src/Utils/GeneratePass.java b/src/Utils/GeneratePass.java index 0888f05..33f40f5 100644 --- a/src/Utils/GeneratePass.java +++ b/src/Utils/GeneratePass.java @@ -21,9 +21,35 @@ public class GeneratePass { } else { StringBuilder sb = new StringBuilder(longitud); char c; + char lastChar = '\u0000'; //lastChar valor null for (int i = 0; i < sb.capacity(); ++i) { - c = (char) ThreadLocalRandom.current().nextInt(33, 126 + 1); + boolean repeat; + int count; + do { + repeat = false; + count = 0; + c = (char) ThreadLocalRandom.current().nextInt(33, 126 + 1); + for (int j = 0; j < i; j++) { + if (sb.charAt(j) == c) { + count++; + } + if (count >= 2) { + repeat = true; + break; + } + } + if (c == lastChar) { + repeat = true; + } else if (Character.isLetter(c) && Character.isLetter(lastChar)) { + if (Character.isUpperCase(c) == Character.isUpperCase(lastChar)) { + repeat = true; + } + } else if (Character.isDigit(c) && Character.isDigit(lastChar)) { + repeat = true; + } + } while (repeat); sb.insert(i, c); + lastChar = c; } return sb.toString(); }