Re: UTF-8 Hashing

2009-04-24 Thread starryrendezv...@gmail.com
On Apr 23, 3:39 pm, Jean-Marc Desperrier jmd...@alussinan.org wrote: Nelson B Bolyard wrote: Is that python code?  I thought it was JavaScript. Yes, you're right, I had a really too quick look at it :-) On a second thought, I just had a look at this page:

Re: UTF-8 Hashing

2009-04-24 Thread starryrendezv...@gmail.com
Right, this seems to work very well. I consider it solved. Here is the corrected code: hash: function(str,method) { var converter = Components.classes[@mozilla.org/intl/ scriptableunicodeconverter].createInstance (Components.interfaces.nsIScriptableUnicodeConverter);

Re: UTF-8 Hashing

2009-04-23 Thread Jean-Marc Desperrier
Nelson B Bolyard wrote: Is that python code? I thought it was JavaScript. Yes, you're right, I had a really too quick look at it :-) -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto

Re: UTF-8 Hashing

2009-04-22 Thread starryrendezv...@gmail.com
If it helps, here is the code I currently utilize; hash: function(str,method) { var hash_engine = Components.classes[@mozilla.org/security/hash; 1].createInstance().QueryInterface (Components.interfaces.nsICryptoHash); switch(method) {

Re: UTF-8 Hashing

2009-04-22 Thread Nelson B Bolyard
starryrendezv...@gmail.com wrote, On 2009-04-22 07:40: If it helps, here is the code I currently utilize; [snip] I suspect (that is, guess) that your problem is at one of these two places: 1. Perhaps the following code does not pass the UTF8 string you expect it to pass to the hash algorithm.

Re: UTF-8 Hashing

2009-04-22 Thread Jean-Marc Desperrier
starryrendezv...@gmail.com wrote: hash: function(str,method) { [...] str.charCodeAt(i) python quite probably outputs the value of str.charCodeAt(i) as some variant of a UTF-16 value. Or UCS-2 with no handling of surrogates. Under which format is the string inside the file that md5sum

Re: UTF-8 Hashing

2009-04-22 Thread Nelson B Bolyard
Jean-Marc Desperrier wrote, On 2009-04-22 12:17 PDT: starryrendezv...@gmail.com wrote: hash: function(str,method) { [...] str.charCodeAt(i) python quite probably outputs the value of str.charCodeAt(i) as some variant of a UTF-16 value. Or UCS-2 with no handling of surrogates. Under

Re: UTF-8 Hashing

2009-04-22 Thread Mook
starryrendezv...@gmail.com wrote: If it helps, here is the code I currently utilize; hash: function(str,method) { var hash_engine = Components.classes[@mozilla.org/security/hash; 1].createInstance().QueryInterface (Components.interfaces.nsICryptoHash); var