| 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 |
| 21 | function hash_encrypt(a) {\r |
| 22 | return hex_sha1(a);\r |
| 23 | }\r |
| 24 | \r |
| 25 | var hexa_h = "0123456789abcdef";\r |
| 26 | \r |
| 27 | function dechex(a) {\r |
| 28 | return hexa_h.charAt(a);\r |
| 29 | }\r |
| 30 | \r |
| 31 | function hexdec(a) {\r |
| 32 | return hexa_h.indexOf(a);\r |
| 33 | }\r |
| 34 | \r |
| 35 | function hash_xor(a, b) {\r |
| 36 | var c,i,j,k;\r |
| 37 | c = "";\r |
| 38 | i = a.length;\r |
| 39 | j = b.length;\r |
| 40 | if (i < j) {\r |
| 41 | var d;\r |
| 42 | d = a; a = b; b = d;\r |
| 43 | k = i; i = j; j = k;\r |
| 44 | }\r |
| 45 | for (k = 0; k < j; k++)\r |
| 46 | c += dechex(hexdec(a.charAt(k)) ^ hexdec(b.charAt(k)));\r |
| 47 | for (; k < i; k++)\r |
| 48 | c += a.charAt(k);\r |
| 49 | return c;\r |
| 50 | }\r |