我想知道我怎么可以生成C#一个强大而安全的密码。
我GOOGLE了一点点,看到这个公式在维基百科上,其中→
是密码的长度和 N
是可能的符号数:
另外,我发现这个问题,但由于某些原因,该方法 Membership.GeneratePassword
只返回1位,这绝对没有密码的一个随机数。其余所有的解决方案,是非常慢的(> = 0.5秒)。
我需要帮助实现这个公式(我不知道从哪里开始)。您也可以提出另一种解决方案或者解释为什么 GeneratePassword
是行不通的。
我只是想在linqpad如下:
System.Web.Security.Membership.GeneratePassword(25,10)
这是我得到的密码:
[XTJ_67g.i / ag1rL)6_Yv> * +%
或者,如果这还不够安全,试试这个:
System.Web.Security.Membership.GeneratePassword(128,100)
运行时,它的三倍这让我的情况如下:
|c^.:?m)#q+(]V;}[Z(})/?-;$]+@!|^/8*_9.$&.&!(?=^!Wx?[@%+&-@b;)>N;&+*w[>$2+_$%l;+h+#zhs^{e?&=*(}X_%|:}]]}*X[+)Er%J/-=;Q0{:+=%c7:^$ /:_)hxF+*){2|;(>:*N^+!_&|}B.$})?[V=[+v({-:-@9-Z$j?.[-}(@MHx+}(}Mz_S(7#4}{..>@G|!+++{+C=|_}=+r^@&$0;L*|kz-;$++/N3$=}?;%&]]*/^#^!+ :*{]-x^$g{|?*))_=B@^.#%L;g|+)#[nq}?y(_(m;]S^I$*q=l-[_/?}&-!k^(+[_{Z|&:^%!_)!=p%=)=wYd-#.UP$%s1{*l%+[%?!c+7=@=.;{+M)!^}&d/]{];(&}这时间比第二少的方式,顺便说一句。该框架是你的朋友。
请参阅http://msdn.microsoft.com/en-us/library/system.web.security.membership.generatepassword.aspx
I was wondering how I can generate a strong and secure password in C#.
I googled a little bit and saw this formula in Wikipedia, where L
is the length of the password and N
is the number of possible symbols:
Also, I've found this question, but for some reason the method Membership.GeneratePassword
just returns a random number with 1 digit, which absolutely no password. All the rest solutions, were very slow (>= 0.5 secs).
I need help implementing this formula (I don't know where to start). You may also suggest another solution or explain why the GeneratePassword
isn't working.
I just tried the following in linqpad:
System.Web.Security.Membership.GeneratePassword(25, 10)
This is the password I got:
[XTJ_67g.i/ag1rL)6_Yv>*+%
Or, if that's not secure enough, try this:
System.Web.Security.Membership.GeneratePassword(128, 100)
which got me the following when running it three times:
|c^.:?m)#q+(]V;}[Z(})/?-;$]+@!|^/8*_9.$&.&!(?=^!Wx?[@%+&-@b;)>N;&+*w[>$2+_$%l;+h+#zhs^{e?&=*(}X_%|:}]]}*X[+)Er%J/-=;Q0{:+=%c7:^$ /:_)hxF+*){2|;(>:*N^+!_&|}B.$})?[V=[+v({-:-@9-Z$j?.[-}(@MHx+}(}Mz_S(7#4}{..>@G|!+++{+C=|_}=+r^@&$0;L*|kz-;$++/N3$=}?;%&]]*/^#^!+ :*{]-x^$g{|?*))_=B@^.#%L;g|+)#[nq}?y(_(m;]S^I$*q=l-[_/?}&-!k^(+[_{Z|&:^%!_)!=p%=)=wYd-#.UP$%s1{*l%+[%?!c+7=@=.;{+M)!^}&d/]{];(&}
this took way less than a second, btw. The framework is your friend.
See http://msdn.microsoft.com/en-us/library/system.web.security.membership.generatepassword.aspx