Petrunov
Petrunov

Reputation: 774

Javascript equivalent for PHP's md5() which will also work with multibyte strings?

EDIT: the script mentioned in the question, and the other script pointed among the answers, both work just fine with multibyte strings - turned out my problem was elsewhere.

Does anyone know of such implementation? The script at http://phpjs.org/functions/view/469 works well, just not on multibyte strings.

Upvotes: 2

Views: 3182

Answers (2)

Ayman Hourieh
Ayman Hourieh

Reputation: 137156

This implementation seems to handle UTF-8 strings correctly. If you want to test the demo, make sure you change the encoding of the page to UTF-8 in your browser settings first.

Upvotes: 4

Greg
Greg

Reputation: 321638

The script you've posted has str = utf8_encode(str);.
You should probably remove this line and pass in your Cyrillic as UTF-8.

Upvotes: 1

Related Questions