Generate a Hash from string in Javascript

前端 未结 22 1340
不知归路
不知归路 2020-11-22 03:34

I need to convert strings to some form of hash. Is this possible in JavaScript?

I\'m not utilizing a server-side language so I can\'t do it that way.

22条回答
  •  眼角桃花
    2020-11-22 04:37

    If you want to avoid collisions you may want to use a secure hash like SHA-256. There are several JavaScript SHA-256 implementations.

    I wrote tests to compare several hash implementations, see https://github.com/brillout/test-javascript-hash-implementations.

    Or go to http://brillout.github.io/test-javascript-hash-implementations/, to run the tests.

提交回复
热议问题