From 1ce71de003d02f1b1c0e4a6ddd65cdb087d594c3 Mon Sep 17 00:00:00 2001 From: Renard Date: Fri, 27 Sep 2019 12:55:20 -0300 Subject: Añadido: Generación de contraseña para posts --- src/App.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/App.js b/src/App.js index c61ba33..4237784 100644 --- a/src/App.js +++ b/src/App.js @@ -60,6 +60,29 @@ class App extends Component { } else { this.setState({ nightMode: JSON.parse(_nightMode) }); } + let password = localStorage.getItem("password"); + if (password === null) { + localStorage.setItem("password", this.genPassword()); + } + } + + genPassword() { + let pass = ""; + for (let i = 0; i < 10; i++) { + let x = Math.round(Math.random() * 2); + switch (x) { + case 0: + pass += String.fromCharCode(48 + Math.round(Math.random() * 9)); + break; + case 1: + pass += String.fromCharCode(65 + Math.round(Math.random() * 25)); + break; + case 2: + pass += String.fromCharCode(97 + Math.round(Math.random() * 25)); + break; + } + } + return pass; } componentDidUpdate() { -- cgit v1.2.1-18-gbd029