Prev: Scalable Key Cryptography – New Cryptography for Your Perusal
Next: How to find out the entropy of my keyfile?
From: Ilmari Karonen on 28 Dec 2009 23:02 On 2009-12-27, asli <koksal.a(a)gmail.com> wrote: > On Dec 27, 5:12 am, unruh <un...(a)wormhole.physics.ubc.ca> wrote: >> On 2009-12-27, asli <koksa...(a)gmail.com> wrote: >> >> > I want to calculate the strength of the password. But my question is >> > related to the entropy of the characters. So I have the program that >> > calculates the frequencies of the symbols, single character, bigrams, >> > word starting and ending chars. >> >> > I want to calculate the entropy of the given password based on these >> > character probabilities. >> >> > I know that the entropy is defined as: >> > H(X)= - Sum [P(x_i).logP(x_i) ] >> > for a random variable X, with n, outcomes { x_i : i = 1,... ,n}. >> >> > If I want to calculate the entropy of a single character, how will I >> > use this formula? As unruh noted, entropy in this sense ("Shannon entropy") is a property of a probability distribution. It does not make sense to talk about the entropy of a single, fixed value (except to state that it is zero, which is technically true, if trivial). When we speak of "the entropy of a password", that's really shorthand for the entropy of the probability distribution according to which the password was randomly chosen. That shorthand makes little sense for user-chosen passwords, since we generally cannot know the distribution according to which a given user chooses their passwords. [snip] > Thanks a lot for your reply. That is the reason why everything gets > complicated. If you check the below link, there exists a strength > checker. The important part for me is the area that shows the entropy. > > http://www.certainkey.com/demos/password/ > > I really wonder how they calculate it. The code is: > > function calcEntropy(pswd){ > var ai=new Array(); > for(var i=0;i<pswd.length;i++){ > var c=pswd.charCodeAt(i); > if(ai[c]==undefined) > ai[c]=0; > ai[c]++; > } > entropy=0; > for(var i=0;i<ai.length;i++){ > if(ai[i]!=undefined &&ai[i]!=0){ > var d=ai[i]/ pswd.length; > entropy+=d * Math.log(1.0 / d); > } > } > entropy /=Math.log(2); What this code calculates, if I'm reading it correctly, is the entropy of picking a single random character from the password. (The rest, which I snipped, just seems truncate the result to two decimal places, Rube Goldberg style. It could all be replaced with a simple "return entropy.toFixed(2);" statement.) Anyway, I wouldn't consider this method at all useful as an indicator of password strength. For example, it returns the same value for both "abcdefghijklmnopqrstuvwxyz" and "poskvlqbtacynmxwfgirdjuhze", even though the latter is obviously a stronger password. -- Ilmari Karonen To reply by e-mail, please replace ".invalid" with ".net" in address. |