Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strong Password Generator Function #33

Merged
Merged
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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,8 @@ Defined method.
- railwayTimeConversion
- sort
- ext
- emailValidator
- strongPasswordGenerator

#### Date to Week-day => dateToDay('dd/mm/yyyy')
// The dateToDay method takes a string date and returns the
Expand Down Expand Up @@ -1411,6 +1413,16 @@ The ext method returns the extension of the given file name.
console.log(solverjs.ext("mypic.jpg"));
// The output is : .jpg

#### Check Whether the string is an valid email or not => emailValidator
// emailValidator function check whether the string passed is a valid email or not and return boolean values accordingly.
console.log(solverjs.emailValidator("[email protected]"));
// The output is : true

#### strongPasswordGenerator
// strongPasswordGenerator function return a strong password of the length that is being passed.
console.log(solverjs.strongPasswordGenerator(12));
// The output is : 2!$ytv6UJxZ7

## Matrix Operations
// The matrix mathod are highly optimized.

Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ let {
ext,
title,
dateDelta,
emailValidator
emailValidator,
strongPasswordGenerator
} = require('./src/utils/utils');

// matrix
Expand Down Expand Up @@ -761,6 +762,7 @@ module.exports = {
title,
dateDelta,
emailValidator,
strongPasswordGenerator,
// matrix
matAdd,
matSub,
Expand Down
10 changes: 9 additions & 1 deletion src/utils/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,12 @@ export function dateDelta(data1: string, data2: string): false | {
* @returns return true if the email is a correct email else return false
* @example emailValidator('[email protected]') => true
*/
export function emailValidator(email: string): boolean;
export function emailValidator(email: string): boolean;

/**
* strong password generator.
* @param {Number} length
* @returns returns the strong password based on the length given
* @example strongPasswordGenerator(12) => 2!$ytv6UJxZ7
*/
export function strongPasswordGenerator(length: number): string;
23 changes: 22 additions & 1 deletion src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,26 @@ let emailValidator = (email) => {
}else{
return false
}
}

/**
* strong password generator.
* @param {Number} length
* @returns returns the strong passeword based on the length given
* @example strongPasswordGenerator(12) => 2!$ytv6UJxZ7
*/
let strongPasswordGenerator = (length) => {
let characters = '0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*ABCDEFGHIJKLMNOPQRSTUVWXYZ';

let password = '';

for(let i = 0;i<length;i++){
let randomNumber = Math.floor(Math.random() * characters.length);

password += characters.substring(randomNumber, randomNumber +1);
}

return password
}

module.exports = {
Expand All @@ -401,5 +421,6 @@ module.exports = {
ext,
title,
dateDelta,
emailValidator
emailValidator,
strongPasswordGenerator
}