On Jan 17, 4:10 am, dhruvbird <[email protected]> wrote:
> but:
> x='Велихов,_Евгений_Павлович.jpeg'
> c = require('crypto')
> md5 = c.createHash('md5')
> md5.update(x)
> md5.digest('hex')
>
> shows: 2fb2004e85d734547647e45a72863d13

It's a character encoding problem when you're pasting the string as-
is. If you use the raw bytes, you will get the right answer:

crypto.createHash('md5').update(new
Buffer([0xD0,0x92,0xD0,0xB5,0xD0,0xBB,0xD0,0xB8,0xD1,0x85,0xD0,0xBE,
0xD0,0xB2,0x2C,0x5F,0xD0,0x95,0xD0,0xB2,0xD0,0xB3,0xD0,0xB5,0xD0,0xBD,
0xD0,0xB8,0xD0,0xB9,0x5F,0xD0,0x9F,0xD0,0xB0,0xD0,0xB2,0xD0,0xBB,
0xD0,0xBE,0xD0,0xB2,0xD0,0xB8,0xD1,0x87,0x2E,0x6A,
0x70,0x65,0x67])).digest('hex');

// in a REPL this correctly displays:
'2d20149202635b06b67af28545739192'

You can use a module like iconv/iconv-lite to convert between
encodings.

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to