Post by Jay on Jul 7, 2006 7:23:42 GMT -8
Name: Advanced Password Generation in Profile
Live Preview: dorkxd.com/?script=random_pass_gen
Crossbrowser: Yes
Placement: Main Footer
Editing: None, but read below before snagging the code.
Yeah, I got playing around with random things this morning and a new code came to mind. Check out the live preview, just under the Password sections. First select a strength from the drop down, then press Generate. Keep generating until your comfortable with what you see. Click your password in the input box. A message will now appear; don't forget to read it before clicking Ok.
Passwords are generated in alphanumerical, special, and ASCII characters; all of which are compatable characters to use as a ProBoards password. Now that I hope you've read this far, let's move on to the code.
<script type="text/javascript">
<!--
/*
Advanced Password Generator in Profile - Created by Jay
Please do not edit or distribute without permission.
Please leave this copyright header intact.
*/
// Do NOT edit below this line
var the_chars = new String();
the_chars +=
'1234567890' + // number generation
'AbCdEfGhIjKlMnOpQrStUvWxYz' + // upper/lower case generation
'aBcDeFgHiJkLmNoPqRsTuVwXyZ' + // upper/lower case generation
'~`!@#$%^&*\(\)-_+=\[\]\\\|<>\/,\.?"\':\;' + // special character generation
'¢£¤¥§©®«»±¶¼½¾¿ØæÞß°'; // ASCII generation
function gen_pass(the_length) {
var new_pass = '';
var pass_id = document.getElementById('passgen');
if (the_length != parseInt(the_length) || !the_length.match(/[\d.]/)) {
return window.alert('Please select strength.');
}
else {
for (var gen = parseInt(the_length); gen >= 0; gen--) {
new_pass += the_chars.charAt(Math.floor(Math.random() * (the_chars.length - 1)));
continue;
}
return pass_id.value = new_pass;
}
}
function do_pass_gen() {
var tabs = document.getElementsByTagName('TABLE');
for (var ta = tabs.length - 1; ta >= 0; ta--) {
var tab_obj = tabs.item(ta);
if (tab_obj.width == 650 && tab_obj.cellPadding == 2 && tab_obj.firstChild.firstChild.firstChild.innerHTML.match(/Username:/)) {
var pass_row = tab_obj.insertRow(3);
var pass_cell1 = pass_row.insertCell(0);
pass_cell1.innerHTML = '<font size="-1">Random Generator:</font>';
var pass_cell2 = pass_row.insertCell(1);
pass_cell2.appendChild(pass_holder);
pass_cell2.appendChild(document.createElement('BR'));
pass_cell2.appendChild(new_sel);
pass_cell2.appendChild(generate);
var pass_cell3 = pass_row.insertCell(2);
pass_cell3.innerHTML = '<font size="-2">Select your password strength from the drop down and click Generate. Generates a random password up to 50 characters long.</font>';
}
}
}
var new_sel = document.createElement('SELECT');
var pass_holder = document.createElement('INPUT');
var generate = document.createElement('INPUT');
new_sel.setAttribute('id', 'rand');
new_sel.style.marginTop = 3;
new_sel[0] = new Option('Strength:');
new_sel[1] = new Option(6, 6, null, null);
new_sel[2] = new Option(10, 10, null, null);
new_sel[3] = new Option(20, 20, null, null);
new_sel[4] = new Option(35, 35, null, null);
new_sel[5] = new Option(50, 50, null, null);
new_sel[5].style.color = '#FF0000';
pass_holder.setAttribute('id', 'passgen');
pass_holder.setAttribute('type', 'text');
pass_holder.setAttribute('size', 35);
pass_holder.onfocus = function() {
this.select();
}
pass_holder.onclick = function() {
if (this.value.length != 0) {
window.alert('Your new password has been selected.\nOnce you close this alert, press Ctrl + C to copy it.\nRemember to keep your passwords in a safe place.');
}
}
generate.setAttribute('type', 'button');
generate.setAttribute('value', 'Generate');
generate.style.marginLeft = 3;
generate.onclick = function() {
var rand_id = document.getElementById('rand');
gen_pass(this.previousSibling.options[this.previousSibling.options.selectedIndex].value);
}
if (document.modifyForm && document.modifyForm.password) {
do_pass_gen();
}
//-->
</script>
Jay
Live Preview: dorkxd.com/?script=random_pass_gen
Crossbrowser: Yes
Placement: Main Footer
Editing: None, but read below before snagging the code.
Yeah, I got playing around with random things this morning and a new code came to mind. Check out the live preview, just under the Password sections. First select a strength from the drop down, then press Generate. Keep generating until your comfortable with what you see. Click your password in the input box. A message will now appear; don't forget to read it before clicking Ok.
Passwords are generated in alphanumerical, special, and ASCII characters; all of which are compatable characters to use as a ProBoards password. Now that I hope you've read this far, let's move on to the code.
<script type="text/javascript">
<!--
/*
Advanced Password Generator in Profile - Created by Jay
Please do not edit or distribute without permission.
Please leave this copyright header intact.
*/
// Do NOT edit below this line
var the_chars = new String();
the_chars +=
'1234567890' + // number generation
'AbCdEfGhIjKlMnOpQrStUvWxYz' + // upper/lower case generation
'aBcDeFgHiJkLmNoPqRsTuVwXyZ' + // upper/lower case generation
'~`!@#$%^&*\(\)-_+=\[\]\\\|<>\/,\.?"\':\;' + // special character generation
'¢£¤¥§©®«»±¶¼½¾¿ØæÞß°'; // ASCII generation
function gen_pass(the_length) {
var new_pass = '';
var pass_id = document.getElementById('passgen');
if (the_length != parseInt(the_length) || !the_length.match(/[\d.]/)) {
return window.alert('Please select strength.');
}
else {
for (var gen = parseInt(the_length); gen >= 0; gen--) {
new_pass += the_chars.charAt(Math.floor(Math.random() * (the_chars.length - 1)));
continue;
}
return pass_id.value = new_pass;
}
}
function do_pass_gen() {
var tabs = document.getElementsByTagName('TABLE');
for (var ta = tabs.length - 1; ta >= 0; ta--) {
var tab_obj = tabs.item(ta);
if (tab_obj.width == 650 && tab_obj.cellPadding == 2 && tab_obj.firstChild.firstChild.firstChild.innerHTML.match(/Username:/)) {
var pass_row = tab_obj.insertRow(3);
var pass_cell1 = pass_row.insertCell(0);
pass_cell1.innerHTML = '<font size="-1">Random Generator:</font>';
var pass_cell2 = pass_row.insertCell(1);
pass_cell2.appendChild(pass_holder);
pass_cell2.appendChild(document.createElement('BR'));
pass_cell2.appendChild(new_sel);
pass_cell2.appendChild(generate);
var pass_cell3 = pass_row.insertCell(2);
pass_cell3.innerHTML = '<font size="-2">Select your password strength from the drop down and click Generate. Generates a random password up to 50 characters long.</font>';
}
}
}
var new_sel = document.createElement('SELECT');
var pass_holder = document.createElement('INPUT');
var generate = document.createElement('INPUT');
new_sel.setAttribute('id', 'rand');
new_sel.style.marginTop = 3;
new_sel[0] = new Option('Strength:');
new_sel[1] = new Option(6, 6, null, null);
new_sel[2] = new Option(10, 10, null, null);
new_sel[3] = new Option(20, 20, null, null);
new_sel[4] = new Option(35, 35, null, null);
new_sel[5] = new Option(50, 50, null, null);
new_sel[5].style.color = '#FF0000';
pass_holder.setAttribute('id', 'passgen');
pass_holder.setAttribute('type', 'text');
pass_holder.setAttribute('size', 35);
pass_holder.onfocus = function() {
this.select();
}
pass_holder.onclick = function() {
if (this.value.length != 0) {
window.alert('Your new password has been selected.\nOnce you close this alert, press Ctrl + C to copy it.\nRemember to keep your passwords in a safe place.');
}
}
generate.setAttribute('type', 'button');
generate.setAttribute('value', 'Generate');
generate.style.marginLeft = 3;
generate.onclick = function() {
var rand_id = document.getElementById('rand');
gen_pass(this.previousSibling.options[this.previousSibling.options.selectedIndex].value);
}
if (document.modifyForm && document.modifyForm.password) {
do_pass_gen();
}
//-->
</script>
Jay