Mit diesem JavaScript können Sie einen Passwortgernerator auf Ihrer Homepage erzeugen.
Autor: unbekannt
zur Demo
in <head> einfügen
<script type="text/javascript">
<!--gefunden auf http://www.scriptwelt.org --> <!-- Begin
function getRandomNum(lbound, ubound) {
return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}
function getRandomChar(number, lower, upper, other, extra) {
var numberChars = "0123456789";
var lowerChars = "abcdefghijklmnopqrstuvwxyz";
var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var otherChars = "`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/? ";
var charSet = extra;
if (number == true)
charSet += numberChars;
if (lower == true)
charSet += lowerChars;
if (upper == true)
charSet += upperChars;
if (other == true)
charSet += otherChars;
return charSet.charAt(getRandomNum(0, charSet.length));
}
function getPassword(length, extraChars, firstNumber, firstLower, firstUpper, firstOther,
latterNumber, latterLower, latterUpper, latterOther) {
var rc = "";
if (length > 0)
rc = rc + getRandomChar(firstNumber, firstLower, firstUpper, firstOther, extraChars);
for (var idx = 1; idx < length; ++idx) {
rc = rc + getRandomChar(latterNumber, latterLower, latterUpper, latterOther, extraChars);
}
return rc;
}
// End -->
</script>
in <body> einfügen
<form name="myform">
<table border=0 class=format>
<tr>
<td>
Erste Zeichen kann ein:
</td>
<td>
<input type=checkbox name=firstNumber checked>eine Nummer
<input type=checkbox name=firstLower checked>in Kleinschrift
<input type=checkbox name=firstUpper checked>in Grosschrift
<input type=checkbox name=firstOther>ein anderes Zeichen
</td>
</tr>
<tr>
<td>
Letztes Zeichen kann sein:
</td>
<td>
<input type=checkbox name=latterNumber checked>eine Nummer
<input type=checkbox name=latterLower checked>in Kleinschrift
<input type=checkbox name=latterUpper checked>in Grosschrift
<input type=checkbox name=latterOther>ein anderes Zeichen
</td>
</tr>
<tr>
<td>
Passwortlänge:
</td>
<td>
<input type=text name=passwordLength value="6" size=3>
</td>
</tr>
<tr>
<td>
Extra Passwort-Zeichen:
</td>
<td>
<input type=text name=extraChars size=20>
</td>
</tr>
</table>
</td>
</tr>
<tr align=center>
<td>
Neues Passwort: <br>
<input type=text name=password size=20>
<br>
<input type=button value="Erzeuge Passwort" onClick="document.myform.password.value =
getPassword(document.myform.passwordLength.value, document.myform.extraChars.value,
document.myform.firstNumber.checked, document.myform.firstLower.checked,
document.myform.firstUpper.checked, document.myform.firstOther.checked,
document.myform.latterNumber.checked, document.myform.latterLower.checked,
document.myform.latterUpper.checked, document.myform.latterOther.checked);">
</form>
</td>
</tr>
</table>
<p><center>
<font face="arial, helvetica" size"-2">http://www.scriptwelt.org<br>
<a href="http://www.scriptwelt.org">das JavaScript Archiv</a></font>
</center><p> |