Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
81 lines (71 loc) · 3.04 KB
/
Copy pathindex.html
File metadata and controls
81 lines (71 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Password Generator</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<style>
textarea, code[password] {
letter-spacing:2px;
}
</style>
</head>
<body>
<div class="container">
<h1>Password Generator</h1>
<div class="col-sm-10 form-group">
<textarea class="form-control col-md-6" rows="10" placeholder="Password will go here" id="passwordPlace"></textarea>
</div>
<div class="col-sm-2 text-center">
<p><button class="btn btn-primary" id="generatePassword">Generate!</button></p>
</div>
<hr style="clear:both">
<article class="markdown-body entry-content" itemprop="mainContentOfPage"><h1>
<a name="user-content-node-pwgen" class="anchor" href="#node-pwgen" aria-hidden="true"><span class="octicon octicon-link"></span></a>node-pwgen</h1>
<p>Easy-to-remember secure password generator, which generates passwords such as <code password="yes">SUPER.Obedient.FISH856</code> and <code password="yes">..INWARDLY.Sweet.Ostrich595..</code> in the fashion of <code>{adverb|adjective}</code> <code>adjective</code> <code>animal{number}</code>, with special character padding. Generation can be customized such as padding length, changing the number of numbers, and declaring a maximum length, in which case you might end up with a password like <code password="2num">-ICY-Hard-CAT58-</code></p>
<hr/>
<p>
See source code and more at <a href="http://github.com/vartan/node-pwgen">github.com/vartan/node-pwgen</a>
</p>
</article>
<script src="pwgen.js"></script>
<script>
var regenerate = function() {
var passwordTextarea = document.getElementById("passwordPlace");
var addedPassword=generatePassword();
passwordTextarea.value = addedPassword+"\n"+passwordTextarea.value
createSelection(passwordTextarea,0,addedPassword.length)
var codeBlocks = document.getElementsByTagName("code")
for (var i = codeBlocks.length - 1; i >= 0; i--) {
var code = codeBlocks[i]
var passwordAttr = code.getAttribute("password")
if(passwordAttr == "yes") {
code.textContent = generatePassword()
} else if(passwordAttr == "2num"){
code.textContent = generatePassword({numbers:2,padding:0,separators:"|"})
}
}
}
document.getElementById("generatePassword").onclick = regenerate;
regenerate();
/** taken from http://stackoverflow.com/questions/646611/programmatically-selecting-partial-text-in-an-input-field*/
function createSelection(field, start, end) {
if( field.createTextRange ) {
var selRange = field.createTextRange();
selRange.collapse(true);
selRange.moveStart('character', start);
selRange.moveEnd('character', end-start);
selRange.select();
} else if( field.setSelectionRange ) {
field.setSelectionRange(start, end);
} else if( field.selectionStart ) {
field.selectionStart = start;
field.selectionEnd = end;
}
field.focus();
}
</script>
</body>
</html>