Skip to content
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
Binary file removed Password-Generator-Extension.zip
Binary file not shown.
Binary file added imgs/copy-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified imgs/icon-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified imgs/icon-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 67 additions & 32 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,79 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="styles/style.css" />
<title>Password Generator</title>
<title>KeyWeaver</title>
</head>
<body>
<div class="form">
<div class="headerbox">
<div class="title">Password Generator</div>
<img src="imgs/icon-64.png" id="logo" alt="Logo" />
</div>
<div class="form">
<div class="headerbox">
<div class="left-header">
<div class="hburger-box" id="hburger-box">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</div>
<div class="title">KeyWeaver</div>
</div>
<img class="logo" src="imgs/icon-64.png" id="logo" alt="Logo" />
</div>
<div class="input-main">
<div class="input-container ic1">
<input id="plaintext" class="input" type="password" placeholder=" " />
<img src="imgs/eye-off.png" id="eyeicon" alt="Eye" />
<div class="cut"></div>
<label for="plaintext" class="placeholder">Enter password</label>
</div>


<div class="input-container ic2">
<input id="keyword" class="input" type="text" placeholder=" " />
<div class="cut"></div>
<label for="website" id="website" class="placeholder">Enter website</label>
</div>
</div>



<div class="input-container ic1">
<input id="plaintext" class="input" type="password" placeholder=" " />
<img src="imgs/eye-off.png" id="eyeicon" alt="Eye" />
<div class="cut"></div>
<label for="plaintext" class="placeholder">Enter password</label>
</div>
<br /><br />

<div class="input-container ic2">
<input id="keyword" class="input" type="text" placeholder=" " />
<div class="cut"></div>
<label for="website" id="website" class="placeholder"
>Enter website</label
>
</div>

<button type="text" id="submit" class="button">Generate</button>
<button type="text" id="copy" class="button">Copy</button>
<br />

<div class="output-container">
<input id="output" class="input" type="text" placeholder="" />
</div>
<p id="copy-confirm" class="copy"></p>

<br /><br /><br /><label for="version" id="version" class="version"
>1.2.0</label
>
</div>
<div class="options-container">
<div class="checkbox-container">
<label class="switch-label">
Special Characters
<label class="switch">
<input type="checkbox" />
<span class="slider"></span>
</label>
</label>

<label class="switch-label">
Numbers
<label class="switch">
<input type="checkbox" />
<span class="slider"></span>
</label>
</label>
</div>
<div class="menu-container">
<select id="menu" class="menu" name="menu">
<option value="16">16 Characters</option>
<option value="12">12 Characters</option>
<option value="8">8 Characters</option>
</select>
</div>
</div>





<div class="output-container">
<input id="output" class="input" type="text" placeholder="" />
<img class="copy" src="imgs/copy-64.png" id="copyimg" alt="copyimg" />
</div>
<label for="version" id="version" class="version">2.2.0</label>
</div>

<script src="scripts/script.js"></script>
</body>
Expand Down
41 changes: 28 additions & 13 deletions scripts/script.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/* global chrome */

function convertAscii(array) {
for (let i = 0; i < array.length; i++) {
let value = array[i] / 2;
if (value < 32) {
value += 32;
}
if (value === 127) {
if (value >= 127) {
value -= 1;
}
array[i] = value;
Expand Down Expand Up @@ -36,21 +34,27 @@ async function encrypt(plaintext, keyword) {
hash: "SHA-256"
},
hashed,
128
128
);

const hashArray = convertAscii(Array.from(new Uint8Array(key)));
console.log(hashArray);
console.log(hashArray.length);
return String.fromCharCode(...hashArray);
}


async function generatePassword() {
document.getElementById("copy-confirm").innerText = "";
const plaintext = document.getElementById("plaintext").value;
const keyword = document.getElementById("keyword").value;
document.getElementById("output").value = await encrypt(plaintext, keyword);
const menu_value = parseInt(document.getElementById("menu").value);

if (plaintext.length > 0 && keyword.length > 0) {
const encrypted = await encrypt(plaintext, keyword);
document.getElementById("output").value = encrypted.slice(0, menu_value);
} else {
document.getElementById("output").value = "";
}
}




Expand Down Expand Up @@ -82,14 +86,18 @@ function copyToClipboard() {
.writeText(text)
.then(() => {
console.log("Text copied to clipboard:", text);
document.getElementById("copy-confirm").innerText =
"Copied to Clipboard!";


/*document.getElementById("copy-confirm").innerText =
"Copied to Clipboard!";*/
})
.catch((error) => {
console.error("Failed to copy text to clipboard:", error);
});
}



document.getElementById("eyeicon").addEventListener("click", function () {
const plaintext = document.getElementById("plaintext");
const eyeicon = document.getElementById("eyeicon");
Expand All @@ -99,8 +107,15 @@ document.getElementById("eyeicon").addEventListener("click", function () {
});

// Event listeners
document.getElementById("submit").addEventListener("click", generatePassword);
document.getElementById("copy").addEventListener("click", copyToClipboard);
document.getElementById("copyimg").addEventListener("click", copyToClipboard);
document.getElementById("keyword").addEventListener("click", autoFill);
document.getElementById("keyword").addEventListener("input", generatePassword);
document.getElementById("plaintext").addEventListener("input", generatePassword);
document.getElementById("menu").addEventListener("change", generatePassword);


document.getElementById("hburger-box").addEventListener("click", (e) => {
e.currentTarget.classList.toggle("change");
});

autoFill();
autoFill();
Loading