本机JavaScript中是否有可用的单向哈希函数? [英] Are there any one-way hashing functions available in native JavaScript?

查看:87
本文介绍了本机JavaScript中是否有可用的单向哈希函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够基于哈希字符串为用户创建唯一令牌*.例如,我知道我可以使用md5()库,但是由于目的不是加密,所以我想知道是否可以使用开箱即用"的任何东西.原生JavaScript中有没有可用的单向哈希函数?

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 was wondering if there was anything I could use "out of the box." Are there any one-way hashing functions available in native JavaScript?

*我意识到这些并不是严格唯一的.我认为散列冲突的可能性很小.

*I realize these won't be strictly unique. I'm ok with a small chance of hashing collision.

推荐答案

不是我所知道的.

但是,您始终可以使用MD5的JavaScript实现

however, you could always use a JavaScript implementation of MD5

http://pajhome.org.uk/crypt/md5/

这篇关于本机JavaScript中是否有可用的单向哈希函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆