最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

hash - Are there any slow Javascript hashing algorithms like bcrypt? - Stack Overflow

programmeradmin5浏览0评论

I'm not talking about server-side node.js.

I want to use a slow hashing algorithm for a key on the client-side of my site. I have found implementations of SHA-256 which seem to be reliable. I also found this question which lead to the OP creating his own library.

However, I'm not sure if I should just do multiple rounds of SHA hashing or trust some of that code since I'm not a security expert and it doesn't seem to have a large following only being "stared" by 36 people.

What is the best choice in this case? I (basically) cannot change methods once I choose something.

I want a slow hashing (not encryption) algorithm and I would rather it produced a short string. For example, a slow 60 char bcrypt vs fast 70 char SHA-256.

I'm not talking about server-side node.js.

I want to use a slow hashing algorithm for a key on the client-side of my site. I have found implementations of SHA-256 which seem to be reliable. I also found this question which lead to the OP creating his own library.

However, I'm not sure if I should just do multiple rounds of SHA hashing or trust some of that code since I'm not a security expert and it doesn't seem to have a large following only being "stared" by 36 people.

What is the best choice in this case? I (basically) cannot change methods once I choose something.

I want a slow hashing (not encryption) algorithm and I would rather it produced a short string. For example, a slow 60 char bcrypt vs fast 70 char SHA-256.

Share Improve this question edited May 23, 2017 at 11:46 CommunityBot 11 silver badge asked Nov 7, 2012 at 17:42 XeoncrossXeoncross 57.3k83 gold badges271 silver badges371 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

There are currently three key-derivation functions widely considered to be secure against brute force cracking attempts. Key-derivation functions are slightly different from regular hashing algorithms in that they are designed to be slow, even in the face of modern GPU-based putation.

I'll list them in order of theoretical security:

  • PBKDF2 is designed by RSA, based on SHA, and is the algorithm remended by NIST. There's a couple implementations that you could use in a browser.

    Note to Node users: Node's crypto module has a built-in PBKDF2 function. Use that.

  • bcrypt, based on Blowfish, is slightly more secure than PBKDF2. It has been relatively well-tested and verified secure, but does not have a stamp of approval from any standards bodies, if that's a consideration for you. There's a generic JS implementation here.

    Note to Node users: Use node.bcrypt, which performs the putationally expensive stuff on a separate thread.

  • Finally, scrypt is far and away the most theoretically secure (slowest) KDF. Unfortunately, the algorithm is very new, so it has not been validated by rigorous study and testing by the cryptographic munity. It is, however, on track to bee a IETF standard.

    Because the algorithm is so new, it is hard to find implementations. I could only find this half-baked one. While the security benefits are very promising, I would not remend scrypt until both the algorithm itself and its implementations are verified secure.

How do these three actually pare? The scrypt paper has a parison:

Realistically, even PBKDF2 makes it cost-prohibitive for anyone but a government to crack a single 8-character password.

You can always ignore the last 10 characters of the fast SHA-256. Or xor the first 10 characters to be included.

SHA has a variable number of rounds. Two rounds of SHA should be reversible somewhat. I have a vague idea that 20 rounds is considered "safe". 30 rounds should be "highly secure" and 50 rounds doesn't practically improve at all the security.

SHA is designed to be secure -- not by hoping that the cracker has a slow enough machine -- but by mathematical proof. If and when the number of irreversible bits in each round is increased and permuted to the 256 bit hash code, there will never be enough puter power to try all possible sequences that generate that particular hash code. Not even enough energy in the universe to wrap a 256-bit counter.

Unless the string that produces the hash is very small or written on a post-it on somebody's monitor.

发布评论

评论列表(0)

  1. 暂无评论