├── public ├── robots.txt ├── favicon.ico ├── logo192.png ├── logo512.png ├── manifest.json └── index.html ├── src ├── index.js ├── css │ └── index.css └── App.js ├── .gitignore ├── package.json └── README.md /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhijeetSinghRajput/password-generator/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhijeetSinghRajput/password-generator/HEAD/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhijeetSinghRajput/password-generator/HEAD/public/logo512.png -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDom from 'react-dom/client' 3 | 4 | // components 5 | import App from "./App"; 6 | 7 | const root = ReactDom.createRoot(document.getElementById('root')); 8 | root.render( 9 | 10 | ); -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "password-generator", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.17.0", 7 | "@testing-library/react": "^13.4.0", 8 | "@testing-library/user-event": "^13.5.0", 9 | "react": "^18.3.1", 10 | "react-dom": "^18.3.1", 11 | "react-scripts": "5.0.1", 12 | "web-vitals": "^2.1.4" 13 | }, 14 | "scripts": { 15 | "start": "react-scripts start", 16 | "build": "react-scripts build", 17 | "test": "react-scripts test", 18 | "eject": "react-scripts eject" 19 | }, 20 | "eslintConfig": { 21 | "extends": [ 22 | "react-app", 23 | "react-app/jest" 24 | ] 25 | }, 26 | "browserslist": { 27 | "production": [ 28 | ">0.2%", 29 | "not dead", 30 | "not op_mini all" 31 | ], 32 | "development": [ 33 | "last 1 chrome version", 34 | "last 1 firefox version", 35 | "last 1 safari version" 36 | ] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/css/index.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | font-family: sans-serif; 6 | list-style: none; 7 | } 8 | 9 | body { 10 | min-height: 100svh; 11 | width: 100vw; 12 | background-color: #0b111c; 13 | color: #adadad; 14 | display: flex; 15 | align-items: center; 16 | justify-content: center; 17 | } 18 | 19 | #range-box { 20 | display: flex; 21 | align-items: center; 22 | gap: 4px; 23 | } 24 | 25 | .card { 26 | padding: 30px; 27 | border-radius: 20px; 28 | border: 1px solid rgb(65, 70, 86); 29 | margin: auto; 30 | background-color: #1d2533; 31 | } 32 | 33 | .card h1 { 34 | font-size: 24px; 35 | text-align: center; 36 | margin-bottom: 20px; 37 | } 38 | 39 | button { 40 | background-color: royalblue; 41 | color: #f1f1f1; 42 | outline: none; 43 | user-select: none; 44 | border: none; 45 | padding: 12px; 46 | cursor: pointer; 47 | font-size: 16px; 48 | } 49 | 50 | button:hover { 51 | filter: brightness(90%); 52 | } 53 | 54 | .card #input-box { 55 | display: flex; 56 | border-radius: 10px; 57 | overflow: hidden; 58 | border: 3px solid royalblue; 59 | } 60 | 61 | .card input { 62 | outline: none; 63 | flex: 1; 64 | padding: 12px; 65 | background-color: rgb(205, 212, 215); 66 | border: none; 67 | font-size: 16px; 68 | color: royalblue; 69 | font-weight: 600; 70 | } 71 | 72 | .flex-box { 73 | display: flex; 74 | align-items: center; 75 | gap: 16px; 76 | width: max-content; 77 | user-select: none; 78 | padding: 8px 16px; 79 | } 80 | 81 | label { 82 | display: flex; 83 | align-items: center; 84 | gap: 4px; 85 | text-transform: capitalize; 86 | cursor: pointer; 87 | } 88 | 89 | input[type="checkbox"] { 90 | width: 15px; 91 | aspect-ratio: 1; 92 | cursor: pointer; 93 | } 94 | 95 | #message-box { 96 | padding: 8px 12px; 97 | border-radius: 12px; 98 | background-color: white; 99 | max-width: max-content; 100 | text-align: center; 101 | text-transform: lowercase; 102 | position: fixed; 103 | bottom: 5vh; 104 | visibility: hidden; 105 | left: 50%; 106 | transform: translateX(-50%) scale(0); 107 | z-index: 100; 108 | box-shadow: -2px 3px 10px rgba(0, 0, 0, 0.5); 109 | color: rgb(68, 68, 68); 110 | transition: .2s ease-in-out; 111 | opacity: 0; 112 | } 113 | 114 | #message-box.active { 115 | bottom: 10vh; 116 | visibility: visible; 117 | opacity: 1; 118 | transform: scale(1); 119 | transform: translateX(-50%) scale(1); 120 | } 121 | 122 | @media screen and (max-width: 500px) { 123 | .card { 124 | padding: 20px; 125 | width: 90vw; 126 | } 127 | 128 | .flex-box { 129 | padding: 0; 130 | margin: auto; 131 | margin-top: 6px; 132 | } 133 | } -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React, { useCallback, useEffect, useRef, useState } from 'react' 2 | import './css/index.css' 3 | 4 | function App() { 5 | const [numberAllowed, setNumberAllowed] = useState(false); 6 | const [symbolAllowed, setSymbolAllowed] = useState(false); 7 | const [length, setLength] = useState(20); 8 | const [passwoard, setPassword] = useState(''); 9 | const messageRef = useRef(null); 10 | const MIN_LENGTH = 10; 11 | const MAX_LENGTH = 50; 12 | 13 | const alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 14 | const number = "0123456789"; 15 | const symbol = "`./?()[]{}:;#$&*@!\"\\"; 16 | const passwordGenerator = useCallback(() => { 17 | let chars = alpha; 18 | console.log(numberAllowed, symbolAllowed); 19 | if (numberAllowed) chars += chars += number; 20 | if (symbolAllowed) chars += chars += symbol; 21 | 22 | let str = ''; 23 | for (let i = 0; i < length; ++i) { 24 | str += chars[Math.floor(Math.random() * chars.length)]; 25 | } 26 | 27 | setPassword(str); 28 | }, [numberAllowed, symbolAllowed, length, setPassword]); 29 | useEffect( 30 | passwordGenerator, 31 | [numberAllowed, symbolAllowed, length, setPassword] 32 | ); 33 | const copy = () => { 34 | const message = messageRef.current; 35 | if(message){ 36 | message.classList.add('active'); 37 | setTimeout(() => { 38 | message.classList.remove('active'); 39 | }, 2000); 40 | } 41 | 42 | window.navigator.clipboard.writeText(passwoard) 43 | } 44 | 45 | return ( 46 | <> 47 |
copied
48 |
49 |

Password Generator

50 |
51 | 57 | 58 |
59 | 60 |
61 |
62 | setLength(e.target.value)} 69 | /> 70 | {length} 71 |
72 | 76 | 82 |
83 |
84 | 85 | ) 86 | } 87 | 88 | export default App -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser. 13 | 14 | The page will reload when you make changes.\ 15 | You may also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!** 35 | 36 | If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. 39 | 40 | You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | --------------------------------------------------------------------------------