Are there any one-way hashing functions available in native JavaScript?

前端 未结 4 1435
滥情空心
滥情空心 2020-12-13 09:39

I\'d like to be able to create unique tokens* for users based on a hashed string. I know I could, for example, use a md5() library but as the purpose is not cryptographic I

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 09:55

    JavaScript does not have native hashing, but there are many libraries.

    I recommend crypto-js: https://code.google.com/p/crypto-js/

    For example, to use SHA1, you simply:

    
    
    

提交回复
热议问题