Debian Codegraph @

scripts/pvpgn_wol_hash.inc.php

raw symbols SCIP
1 <?php
2 /*
3 * PHP implementation of the PvPGN WOL Password Hash Algorithm.
4
5 * This code is available under the GNU Lesser General Public License:
6 * http://www.gnu.org/licenses/lgpl.txt
7
8 * Original hash funcion Copyright (C) Luigi Auriemma ([email protected])
9 *
10 * Comment:
11 * Original algorithm starts at offset 0x0041d440 of wchat.dat of 4.221 US version
12 * The algorithm is one-way, so the encoded password can NOT be completely decoded!
13
14 */
15 function wol_hash($pass)
16 {
17 if(strlen($pass)<>8)
18 {
19 return false;
20 }
21 $pwd1=$pass;
22 $esi=8;
23 $pwd2=array(null,null,null,null,null,null,null,null);
24 $p1=0;
25 $p2=0;
26 $edx="";
27 for($i=0;$i<8;$i++)
28 {
29 if(ord($pwd1[$p1]) & 1)
30 {
31 $edx = ord($pwd1[$p1]) << 1;
32 $edx &= ord($pwd1[$esi]);
33 }
34 else
35 {
36 $edx = ord($pwd1[$p1]) ^ ord($pwd1[$esi]);
37 }
38 $pwd2[$p2] = $edx;
39 $p2++;
40 $esi--;
41 $p1++;
42 }
43
44
45 $WOL_HASH_CHAR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
46 $p1 = 0;
47 $p2 = 0;
48 for($i=0;$i<8;$i++)
49 {
50 $edx = $pwd2[$p2] & 0x3f;
51 $p2++;
52 $pwd1[$p1] = $WOL_HASH_CHAR[$edx];
53 $p1++;
54 }
55 return $pwd1;
56 }
57
58 ?>