diff --git a/package.json b/package.json index 4237c39..52a18ff 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "axios": "^1.2.2", "classnames": "^2.5.1", "framer-motion": "^10.8.3", + "js-yaml": "^4.1.0", "lodash": "^4.17.21", "lucide-react": "^0.544.0", "prettier": "^3.3.3", diff --git a/src/components/DevAreaTools/PasswordGenerator.jsx b/src/components/DevAreaTools/PasswordGenerator.jsx new file mode 100644 index 0000000..bdc45b4 --- /dev/null +++ b/src/components/DevAreaTools/PasswordGenerator.jsx @@ -0,0 +1,99 @@ +import React, { useState } from "react"; + +export default function PasswordGenerator() { + const [length, setLength] = useState(12); + const [includeUpper, setIncludeUpper] = useState(true); + const [includeLower, setIncludeLower] = useState(true); + const [includeNumbers, setIncludeNumbers] = useState(true); + const [includeSymbols, setIncludeSymbols] = useState(true); + const [password, setPassword] = useState(""); + + const generatePassword = () => { + let charset = ""; + if (includeUpper) charset += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + if (includeLower) charset += "abcdefghijklmnopqrstuvwxyz"; + if (includeNumbers) charset += "0123456789"; + if (includeSymbols) charset += "!@#$%^&*()_+-=[]{}|;:,.<>?"; + if (!charset) return setPassword("โš ๏ธ Select at least one option."); + + let pass = ""; + for (let i = 0; i < length; i++) { + pass += charset.charAt(Math.floor(Math.random() * charset.length)); + } + setPassword(pass); + }; + + const copyPassword = async () => { + if (!password) return; + await navigator.clipboard.writeText(password); + }; + + return ( +
+

+ ๐Ÿ” Password Generator +

+ +
+
+ + setLength(Number(e.target.value))} + className="w-20 text-center bg-[#0f172a] border border-slate-700 rounded-md p-1 text-sm text-slate-200 focus:border-emerald-500 outline-none" + /> +
+ +
+ + + + +
+ +
+ + +
+ +
+

Generated Password

+