home *** CD-ROM | disk | FTP | other *** search
- /*
- 2010 - Copyright by Bee <http://www.honeybeenet.altervista.org>.
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-
- //TODO: added for future uses ???????????????!!!!!!!!
-
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
- //THIS FILE IS UNUSED!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ATM!!!!!!!!!)
-
- /*
- Stolen from https://developer.mozilla.org/en/nsICryptoHash !!!!!!! super!!!!!!!!!!!!
- I've no ideas about how this function works, but it works very well!!!!!!!!!!!!
- This code is magic:
- [toHexString(hash.charCodeAt(i)) for (i in hash)].join("");
- one line, is doing so much!!!!!!!!!!! (from array to hex string, and everything in one hop!!!!)
- */
-
- function beefree_hash_toHexString(charCode) // return the two-digit hexadecimal code for a byte
- {
- return ("0" + charCode.toString(16)).slice(-2);
- }
-
- function beefree_hash_md5_string(str)
- {
- //var str = "hello world";
- var converter =
- Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
- // we use UTF-8 here, you can choose other encodings.
- converter.charset = "UTF-8";
- // result is an out parameter,
- // result.value will contain the array length
- var result = {};
- // data is an array of bytes
- var data = converter.convertToByteArray(str, result);
- var ch = Components.classes["@mozilla.org/security/hash;1"].createInstance(Components.interfaces.nsICryptoHash);
- ch.init(ch.MD5);
- ch.update(data, data.length);
- var hash = ch.finish(false);
- // convert the binary hash data to a hex string.
- var s = [beefree_hash_toHexString(hash.charCodeAt(i)) for (i in hash)].join("");
- // s now contains your hash in hex: should be
- // 5eb63bbbe01eeed093cb22bb8f5acdc3
- return s;
- }
-
-
-
-