1 <?php printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", 'iso-8859-1'); ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml">
6 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
7 <!-- $Id: passencrypt.php,v 1.1 2002-02-24 20:33:24 carstenklapp Exp $ -->
8 <title>Password Encryption Tool</title>
10 Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
12 This file is part of PhpWiki.
14 PhpWiki is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
19 PhpWiki is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with PhpWiki; if not, write to the Free Software
26 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 <h1>Password Encryption Tool</h1>
33 * Seed the random number generator.
35 * better_srand() ensures the randomizer is seeded only once.
37 * How random do you want it? See:
38 * http://www.php.net/manual/en/function.srand.php
39 * http://www.php.net/manual/en/function.mt-srand.php
41 function better_srand($seed = '') {
42 static $wascalled = FALSE;
44 $seed = $seed === '' ? (double) microtime() * 1000000 : $seed;
47 //trigger_error("new random seed", E_USER_NOTICE); //debugging
50 function rand_ascii($length = 1) {
53 for ($i = 1; $i <= $length; $i++) {
54 $s .= chr(rand(40, 126)); // return only typeable 7 bit ascii, avoid quotes
60 $posted = $GLOBALS['HTTP_POST_VARS'];
61 if ($password = $posted['password']) {
63 * http://www.php.net/manual/en/function.crypt.php
65 // Use the maximum salt length the system can handle.
66 $salt_length = max(CRYPT_SALT_LENGTH,
71 // Generate the encrypted password.
72 $encrypted_password = crypt($password, rand_ascii($salt_length));
75 echo "The password was encrypted using a salt length of: $salt_length<br />\n";
76 echo "<p>The encrypted password is:<br />\n<br />\n<strong>$encrypted_password</strong></p>\n";
81 <form action="passencrypt.php" method="post">
82 Enter a password to encrypt: <input type="password" name="password" value="" /> <input type="submit" value="Encrypt" />