Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide demo website for password-generator (Issue #9) #211

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions demo/README.md

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Clemoucloum I would advise here to update the README.md to further describe something like:

Introduction

This is a demonstration of the Password Generator application. This web-based interface is meticulously designed for developers and cybersecurity professionals, providing a robust tool to instantly generate secure, random passwords tailored to specific requirements.

Purpose

The objective of this update is to deliver a comprehensive, user-centric web demo for the password generator application. This interface enables seamless creation and customisation of secure passwords, ensuring they meet the highest security standards.

Features

Customisable Password Length

The password generator offers granular control over password length, allowing users to specify the exact number of characters. Additionally, it supports multiple iterations of varying lengths, ensuring flexibility and adherence to different security policies.

Character Inclusion Options

To cater to diverse security needs and compliance requirements, the application includes:

  • Digits: Users can opt to include or exclude numeric characters (0-9), enhancing the password's complexity as needed.
  • Special Characters: For increased security, users can toggle the inclusion of special characters (e.g., +/), ensuring the generated passwords meet stringent security criteria.

Copy Functionality

The application features an efficient copy-to-clipboard functionality, allowing users to transfer generated passwords with a single click. This streamlines the process of updating and managing passwords across different platforms and applications.

Password Strength Indicator

To provide immediate feedback on the security level of the generated passwords, the application includes a colour-coded strength indicator integrated into the copy button. This indicator evaluates the password's strength based on its length and complexity, ensuring users create highly secure passwords.

Explore the demo to experience how our password generator can enhance your security practices, offering an intuitive and powerful tool for creating, customising, and managing secure passwords with ease.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Project Update for Password Generator
## Introduction
This repository is a fork of the original [Password Generator](https://github.com/sebastienrousseau/password-generator) by [Sebastien Rousseau](https://github.com/sebastienrousseau). We've created this fork to specifically address an enhancement outlined in [Issue #9](https://github.com/sebastienrousseau/password-generator/issues/9).

## Purpose
The purpose of this update is to create a web-based user demo interface of a password generator.

## Features
#### Customizable Password Length:
Users can specify the exact length of the password, with a specific number of iteration of various length.

#### Character Inclusion Options:
- Digits: Users can choose to include or exclude digits (0-9) in the password.
- Special Characters: For added security, the option to include special characters (such as +/) can be toggled on or off.

#### Copy functionality
Once a password is generated, it can be easily copied to the clipboard with a single clic.

#### Password strength indicator
The copy button carries a color indicator based on the length of the password, its purpose is to reflect the strength of the password.
41 changes: 41 additions & 0 deletions demo/demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Password Generator</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<h1>Password Generator</h1>
<div class="display">
<input type="text" id="passwordDisplay" readonly>
<button id="copyButton" onclick="copyPassword()">Copy</button>

</div>
<div class="settings">
<div class="boxSettings">
<div class="checkbox-container">
<input type="checkbox" id="specialChars" name="specialChars" checked>
<label for="specialChars">Include special characters</label>
</div>
<div class="checkbox-container">
<input type="checkbox" id="digits" name="digits" checked>
<label for="specialChars">Include digits</label>
</div>

</div>
<div class="inputSettings">
<input type="number" id="iterationLength" placeholder="Iteration length">
<input type="number" id="iteration" placeholder="Iteration">
<input type="text" id="separator" placeholder="Separator for iterations">
</div>

</div>
<button onclick="generatePassword()">Generate Password</button>
</div>

<script src="script.js"></script>
</body>
</html>
68 changes: 68 additions & 0 deletions demo/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
function generatePassword() {
// Getting input data from html
const lengthInput = document.getElementById('iterationLength');
const separatorInput = document.getElementById('separator')
const iterationInput = document.getElementById('iteration')
const includeSpecialChars = document.getElementById('specialChars').checked;
const includeDigits = document.getElementById('digits').checked;

// Parsing input
const length = parseInt(lengthInput.value);
const iteration = parseInt(iterationInput.value);
const separator = separatorInput.value;

const baseCharset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
const digits = "0123456789";
const specialChars = "+/";

let charset = baseCharset;
if (includeDigits) {
charset += digits;
}
if (includeSpecialChars) {
charset += specialChars;
}


let password = "";

for (let j = 0; j<iteration; j++) {
for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * charset.length);
password += charset.charAt(randomIndex);
}
if(j<iteration-1) {
password+=separator;
}
}

document.getElementById('passwordDisplay').value = password;

// Change the copy button color depending on the length of the code
const copyButton = document.getElementById('copyButton');
if (password.length < 3) {
copyButton.style.backgroundColor = "#8B0000"; // Dark red
}
else if (password.length < 6) {
copyButton.style.backgroundColor = "#FF0000"; // Red
}
else if (password.length < 8) {
copyButton.style.backgroundColor = "#FFFF00"; // Yellow
}
else if (password.length < 11) {
copyButton.style.backgroundColor = "#ADFF2F"; // Green
}
else {
copyButton.style.backgroundColor = "#32CD32"; // Dark green
}

}



function copyPassword() {
const passwordDisplay = document.getElementById('passwordDisplay');
passwordDisplay.select();
document.execCommand('copy');
console.log('password copied')
}
125 changes: 125 additions & 0 deletions demo/styles.css

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, might be worth enhancing your code maybe something like this?

/* Reset default margin and set global styles */
body, html {
height: 100%;
margin: 0;
font-family: Arial, Helvetica, sans-serif;
background-color: #25272a;
}

/* Main container styles */
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
}

/* Password display input styles */
.display input {
width: 100%;
max-width: 50vw;
padding: 2vh;
margin-top: 1vh;
margin-bottom: 2vh;
text-align: center;
font-size: 2vw;
}

/* Settings container styles */
.settings {
display: flex;
flex-direction: row;
justify-content: center;
align-items: flex-start;
width: 100%;
}

/* Checkbox container styles */
.checkbox-container {
display: flex;
flex-direction: row;
align-items: center;
margin-bottom: 1vh;
}

/* Box and input settings container styles */
.boxSettings,
.inputSettings {
display: flex;
flex-direction: column;
padding: 0 2vw;
}

/* Box settings alignment */
.boxSettings {
align-items: flex-start;
}

/* Input styles for box and input settings */
.boxSettings input,
.inputSettings input {
padding: 1vh;
margin-bottom: 2vh;
text-align: center;
font-size: 1.5vw;
}

/* Label styles for box settings */
.boxSettings label {
display: flex;
align-items: center;
margin-bottom: 0.5vh;
color: #e2e2e2;
font-size: 1.5vw;
}

/* Checkbox styles */
input[type="checkbox"] {
position: relative;
top: 0.5vh;
width: 2vw;
height: 2vw;
margin-right: 0.5vw;
cursor: pointer;
appearance: none;
background-color: #fff;
border: 0.2vw solid #0075e2;
border-radius: 0.4vw;
outline: none;
}

/* Checkbox checked styles */
input[type="checkbox"]:checked {
background-color: #0075e2;
background-image: url('data:image/svg+xml;utf8,');
background-position: center;
}

/* Checkbox hover styles */
input[type="checkbox"]:hover {
filter: brightness(0.95);
}

/* Button styles */
button {
padding: 2vh 2vw;
font-size: 1.5vw;
color: white;
background-color: #0075e2;
border: none;
border-radius: 0.5vw;
cursor: pointer;
}

/* Heading styles */
h1 {
color: #e2e2e2;
font-size: 3vw;
}

  1. Updated the font family to font-family: Arial, Helvetica, sans-serif; for better font support and fallback options.
  2. Converted pixel values to vw and vh units for responsive scaling based on the viewport width and height.
  3. Added font sizes in vw units for the password display input, input settings, labels, and heading to ensure they scale proportionally with the viewport width.

Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
body, html {
height: 100%;
margin: 0;
font-family: Arial, sans-serif;
background-color: #25272a;
}




.container {
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
/**background-color: #f7f7f7;**/
}



.display input{
margin-top: 1em;
margin-bottom: 20px;
padding: 20px;
width: 300px;
text-align: center;

}

.settings{
display: flex;
flex-direction: row;
justify-content: center;
width: 100%;
align-items: flex-start;
}


.checkbox-container {
display: flex;
flex-direction: row;
align-items: center;
margin-bottom: 10px;
}

.boxSettings,
.inputSettings {
display: flex;
flex-direction: column;
padding: 0 20px;
}



.boxSettings {
align-items: flex-start;
}



.boxSettings input,
.inputSettings input {
margin-bottom: 20px;
padding: 10px;
text-align: center;
}



.boxSettings label {
color: #e2e2e2;
display: flex;
align-items: center;
margin-bottom: 5px;

}


input[type="checkbox"] {
position: relative;
top: 5px;
/* Size */
width: 20px;
height: 20px;
cursor: pointer;
margin-right: 5px;
/* Appearance */
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background-color: #fff;
border: 2px solid #0075e2;
border-radius: 4px;
outline: none;
}


input[type="checkbox"]:checked {
background-color: #0075e2;
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="%23ffffff" viewBox="0 0 20 20"><path d="M16.7 5.3a1 1 0 00-1.4 0L7.5 13.1 5.2 10.8a1 1 0 10-1.4 1.4l3 3c.4.4 1 .4 1.4 0l8.5-8.5a1 1 0 000-1.4z"/></svg>');
background-position: center;
}


input[type="checkbox"]:hover {
filter: brightness(0.95);
}




button {
padding: 20px 20px;
font-size: 16px;
cursor: pointer;
background-color: #0075e2;
color: white;
border: none;
border-radius: 5px;
}

h1 {
color: #e2e2e2;
}
Loading