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