/* Copyright (c) 2003 Jan-Klaas Kollhof This file is part of the JavaScript o lait library(jsolait). jsolait is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this software; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** Cryptography module. Provides String encryption/decryption and hashing. */ Module("crypto", "0.1.2", function(mod){ /** Returns all all available encrypters. @return An array of encrypters names. */ mod.listEncrypters=function(){ var c=[]; for(var attr in String.prototype){ if(attr.slice(0, 8) == "encrypt_"){ c.push(attr.slice(8)); } } return c; } /** Returns all all available decrypters. @return An array of decrypters names. */ mod.listDecrypters=function(){ var c=[]; for(var attr in String.prototype){ if(attr.slice(0, 8) == "decrypt_"){ c.push(attr.slice(8)); } } return c; } /** Encrypts a string. Parameters but the crypdec parameter are forwardet to the crypdec. @param codec The codec to use. */ String.prototype.encrypt=function(crydec){ var n = "encrypt_" + crydec; if(String.prototype[n]){ var args=[]; for(var i=1;i