Skip to content

Commit

Permalink
Check for common password when creating an encryption key
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Nov 29, 2021
1 parent 28d9c2d commit e30848b
Show file tree
Hide file tree
Showing 4 changed files with 1,040 additions and 7 deletions.
19 changes: 12 additions & 7 deletions app/landing/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { app, dialog } = require("@electron/remote")
const electron = require("electron")
const ipc = electron.ipcRenderer
const path = require("path")
const { aes, rsa, sha } = require("@levminer/lib")
const { aes, rsa, sha, password } = require("@levminer/lib")
const logger = require("@levminer/lib/logger/renderer")

// ? error in window
Expand Down Expand Up @@ -74,15 +74,20 @@ const comparePasswords = () => {
text.textContent = "Minimum password length is 8 characters!"
} else {
if (password_input1.toString() == password_input2.toString()) {
logger.log("Passwords match!")
if (!password.search(password_input1.toString())) {
logger.log("Passwords match!")

text.style.color = "#28A443"
text.textContent = "Passwords match! Please wait!"
text.style.color = "#28A443"
text.textContent = "Passwords match! Please wait!"

password_input1.fill(0)
password_input2.fill(0)
password_input1.fill(0)
password_input2.fill(0)

hashPasswords()
hashPasswords()
} else {
text.style.color = "#CC001B"
text.textContent = "This password is on the list of the top 1000 most common passwords. Please choose a more secure password!"
}
} else {
logger.warn("Passwords dont match!")

Expand Down
2 changes: 2 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const qrcodeConverter = require("./qrcodeConverter")
const typedef = require("./typedef")
const convert = require("./convert")
const time = require("./time")
const password = require("./password/index")

// ? export modules
module.exports = {
Expand All @@ -17,4 +18,5 @@ module.exports = {
typedef,
convert,
time,
password,
}
22 changes: 22 additions & 0 deletions lib/password/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { passwords } = require("./passwords.json")

module.exports = {
/**
* Match the input with the top 1000 passwords
* @param {String} input - Password to check for
* @return {Boolean}
*/
search: (input) => {
let match = false

for (let i = 0; i < passwords.length; i++) {
console.log(i)

if (passwords[i] === input) {
return (match = true)
}
}

return match
},
}
Loading

0 comments on commit e30848b

Please sign in to comment.