Skip to content

Feat: Password Generator - #222

Merged
JeelDobariya38 merged 2 commits into
mainfrom
feat/password-generator
Aug 29, 2026
Merged

JeelDobariya38 merged 2 commits into
mainfrom
feat/password-generator

Conversation

@JeelDobariya38

Copy link
Copy Markdown
Member

Changes Made

  • add a basic password generator.
  • it supports character preference like letters, numbers, symbols & length.

Notes

thanks to @jainil63 for contributing the password generator code under the event of "Beginner Fest | Contribution Race" in discord.

jainil63 and others added 2 commits August 18, 2026 17:16
Signed-off-by: Jeel Dobariya <jeeldobariya38@gmail.com>
@JeelDobariya38 JeelDobariya38 self-assigned this Aug 29, 2026
@JeelDobariya38 JeelDobariya38 added the enhancement New feature or request label Aug 29, 2026
@JeelDobariya38
JeelDobariya38 merged commit d6dde0d into main Aug 29, 2026
1 check passed
@JeelDobariya38
JeelDobariya38 deleted the feat/password-generator branch August 29, 2026 07:53
DEFAULT_PASSWORD_OPTIONS,
);

const [password, setPassword] = useState(() =>

@JeelDobariya38 JeelDobariya38 Aug 29, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@razorblade23 can pls suggest what can be done? Is ai correct or my version is just fine cuz, i thing we just generating password here so if the crypto is predictable it okay i guess

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

AI is right, you should never use basic random generator for something secure, like passwords.

In node, you can use randomInt from node.crypto module as in this example (generated with AI - use caution):

import { randomInt } from 'node:crypto';

/**
 * Generates a cryptographically secure random password.
 * @param {number} length - The length of the password (default: 16).
 * @returns {string} The generated password.
 */
export function generateSecurePassword(length = 16) {
  const lowercase = 'abcdefghijklmnopqrstuvwxyz';
  const uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  const numbers = '0123456789';
  const symbols = '!@#$%^&*()_+-=[]{}|;:,.<>?';
  
  const charset = lowercase + uppercase + numbers + symbols;
  let password = '';

  for (let i = 0; i < length; i++) {
    // randomInt securely picks an index between 0 (inclusive) and charset.length (exclusive)
    const randomIndex = randomInt(0, charset.length);
    password += charset.charAt(randomIndex);
  }

  return password;
}

// Example usage:
const securePassword = generateSecurePassword(18);
console.log(securePassword); 

FYI - save this below

A very good article to read on Android Security practices

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed #227

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants