n'envoie plus le hash du mot de passe directement quand on change de mot de passe
[platal.git] / htdocs / javascript / secure_hash.js
1 /***************************************************************************
2 * Copyright (C) 2003-2006 Polytechnique.org *
3 * http://opensource.polytechnique.org/ *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., *
18 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
19 ***************************************************************************/
20
21 document.write('<script language="javascript" src="javascript/md5.js"></script>');
22 document.write('<script language="javascript" src="javascript/sha1.js"></script>');
23
24 function hash_encrypt(a) {
25 return hex_sha1(a);
26 }
27
28 var hexa_h = "0123456789abcdef";
29
30 function dechex(a) {
31 return hexa_h.charAt(a);
32 }
33
34 function hexdec(a) {
35 return hexa_h.indexOf(a);
36 }
37
38 function hash_xor(a, b) {
39 var c,i,j,k;
40 c = "";
41 i = a.length;
42 j = b.length;
43 if (i < j) {
44 var d;
45 d = a; a = b; b = d;
46 k = i; i = j; j = k;
47 }
48 for (k = 0; k < j; k++)
49 c += dechex(hexdec(a.charAt(k)) ^ hexdec(b.charAt(k)));
50 for (; k < i; k++)
51 c += a.charAt(k);
52 return c;
53 }