I would like to generate SHA1 or similar hashes using only client-side Javascript. In other words, using the Javascript engines provided with IE, FF, and Webkit. I am wondering what hash implementations exist?
我想仅使用客户端Javascript生成SHA1或类似哈希。换句话说,使用IE,FF和Webkit提供的Javascript引擎。我想知道存在什么哈希实现?
3 个解决方案
#1
5
I don't believe there are any built directly into the browser, but there are some well-documented implementations.
我不相信有任何直接构建到浏览器中,但有一些记录良好的实现。
The best I have found is http://code.google.com/p/crypto-js/ which is available via CDN and supports:
我找到的最好的是http://code.google.com/p/crypto-js/,可通过CDN获得并支持:
- MD5
- SHA-1
- SHA-256
- AES
- DES
- Rabbit
- MARC4
- HMAC
- HMAC-MD5
- HMAC-SHA1
- HMAC-SHA256
- PBKDF2
If security matters then use an algorithm that hasn't been broken (yet) and is less subject to various forms of attack (wikipedia has a nice breakdown at the bottom of this article).
如果安全性很重要,那么使用一种尚未被破坏的算法,并且不太受各种形式的攻击(*在本文的底部有一个很好的细分)。
Based on the lack of answers to this question, it doesn't seem like this is native browser functionality. I wish there was, but I could see issues arising from relying on the browser. For example, if a flaw was discovered in an algorithm, it would be difficult to move your users to a new algorithm until you knew all of their browsers supported it (and they had upgraded). If you control the hashing algorithm, then you can deploy a new script whenever you wish.
基于此问题的答案不足,似乎这不是本机浏览器功能。我希望有,但我可以看到依赖浏览器引起的问题。例如,如果在算法中发现缺陷,则在您知道所有浏览器都支持它(并且已经升级)之前,很难将用户移动到新算法。如果您控制散列算法,则可以随时部署新脚本。
#2
3
I'm not sure about built-in hash implementations other than what's already used for associative arrays, but here are some sample implementations with code.
除了已经用于关联数组的内容之外,我不确定内置的哈希实现,但这里有一些带代码的示例实现。
SHA
- http://www.movable-type.co.uk/scripts/sha1.html
- http://www.webtoolkit.info/javascript-sha1.html
- http://jssha.sourceforge.net/
MD5 (with some others included)
MD5(包括其他一些)
#3
0
Movable Type has published a js implementation of SHA1 here: http://www.movable-type.co.uk/scripts/sha1.html
Movable Type在这里发布了SHA的js实现:http://www.movable-type.co.uk/scripts/sha1.html
I'm sure there are plenty of other implementations.
我确信还有很多其他实现。
#1
5
I don't believe there are any built directly into the browser, but there are some well-documented implementations.
我不相信有任何直接构建到浏览器中,但有一些记录良好的实现。
The best I have found is http://code.google.com/p/crypto-js/ which is available via CDN and supports:
我找到的最好的是http://code.google.com/p/crypto-js/,可通过CDN获得并支持:
- MD5
- SHA-1
- SHA-256
- AES
- DES
- Rabbit
- MARC4
- HMAC
- HMAC-MD5
- HMAC-SHA1
- HMAC-SHA256
- PBKDF2
If security matters then use an algorithm that hasn't been broken (yet) and is less subject to various forms of attack (wikipedia has a nice breakdown at the bottom of this article).
如果安全性很重要,那么使用一种尚未被破坏的算法,并且不太受各种形式的攻击(*在本文的底部有一个很好的细分)。
Based on the lack of answers to this question, it doesn't seem like this is native browser functionality. I wish there was, but I could see issues arising from relying on the browser. For example, if a flaw was discovered in an algorithm, it would be difficult to move your users to a new algorithm until you knew all of their browsers supported it (and they had upgraded). If you control the hashing algorithm, then you can deploy a new script whenever you wish.
基于此问题的答案不足,似乎这不是本机浏览器功能。我希望有,但我可以看到依赖浏览器引起的问题。例如,如果在算法中发现缺陷,则在您知道所有浏览器都支持它(并且已经升级)之前,很难将用户移动到新算法。如果您控制散列算法,则可以随时部署新脚本。
#2
3
I'm not sure about built-in hash implementations other than what's already used for associative arrays, but here are some sample implementations with code.
除了已经用于关联数组的内容之外,我不确定内置的哈希实现,但这里有一些带代码的示例实现。
SHA
- http://www.movable-type.co.uk/scripts/sha1.html
- http://www.webtoolkit.info/javascript-sha1.html
- http://jssha.sourceforge.net/
MD5 (with some others included)
MD5(包括其他一些)
#3
0
Movable Type has published a js implementation of SHA1 here: http://www.movable-type.co.uk/scripts/sha1.html
Movable Type在这里发布了SHA的js实现:http://www.movable-type.co.uk/scripts/sha1.html
I'm sure there are plenty of other implementations.
我确信还有很多其他实现。