[JS] Random Password Generator

Place to place any code snippets, completed games, or even uncompleted games for IR users to use.
Post Reply
User avatar
vitinho444
Posts: 2825
Joined: Mon Mar 21, 2011 4:54 pm

[JS] Random Password Generator

Post by vitinho444 »

Hey guys, So i believe i already showed you guys my random password generator somewhere in the forums, but I changed some things, made it prettier and have now a good Open-Source code to share.

So first off, this is a Javascript Random Password Generator. Basically what it does is create a 14 char password using nothing but ABC, abc and some symbols, all this randomly.

Here's a DEMO: http://www.oryzhon.com/random

Some example passwords created by it:
T9!*d9IC77tSjMM
23fcYb4#y8D04
!OU249G84rF9VwX
6sGlB583N8M08*Y
!%03H6x2s3vQy0G
And the source is available on github: https://github.com/vitorpegas95/randomPwGen

Question? Where do I store this strange passwords? Well, What i use is a software created in VB.NET (by me, with help of google ofc) That encrypts data. So basically I have all my passwords on a file :X (encrypted 2 times with different keys ["Hello World" => encrypt with key "abcd" => encrypt with key "efgh"]) and whenever i need some i plug in my USB drive containing the software and the encrypted text and decrypt them.

You can find the software here: http://indie-resource.com/forums/viewto ... =47&t=7763
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
sniko
Posts: 23
Joined: Fri Jan 17, 2014 2:56 pm

Re: [JS] Random Password Generator

Post by sniko »

The javascript is pretty nice, however I question why you've added each letter as an array element, and not had a literal string of "abcdefghijklmnopqrstuvwxyz" and used substring.

For example;

Code: Select all

var strAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#@!$";

var strRandomPass = "";

for (i=0; i<14; i++) { 
    var intRandomNumber = (Math.random() * strAlphabet.length - 1);
    strRandomPass = strRandomPass + strAlphabet.substr(intRandomNumber, 1);   
}
http://jsfiddle.net/ta7n5x8u/1/


I've also sent a pull request to your repo to update the readme.md file: https://github.com/vitorpegas95/randomPwGen/pull/1
Image

Code: Select all

class Life extends Bitch {
  //...
}
User avatar
vitinho444
Posts: 2825
Joined: Mon Mar 21, 2011 4:54 pm

Re: [JS] Random Password Generator

Post by vitinho444 »

:| That would made my life so much easier :'( damn... xD Well I guess I haven't put that much brain into it. Also when I did this I was fairly recent with javascript, still am, but yeah your way seems a lot of work-saving.

I've merged the pull request, thank you for your editions :)
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
Post Reply

Return to “Code Sharing”