用户登录  |  用户注册
首 页商业源码原创产品编程论坛
当前位置:PB创新网文章中心编程技巧Visual C++

穷举密码算法

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2009-03-16 20:35:43
//*******************************************************************//在许多情况下我们需要穷举组合的算法,比如密码词典。//我在程序员大本营上不止一次看到有人需要穷举密码的算法,就写了一个。//这个算法的关键是密码下标进位的问题。//另外本例子中的写文件语句效率比较低,为了降低算法复杂度没有优化。//如果要提高写文件的效率,可以使用缓冲区,分批写入。//*********************************************BREATH.CNPICK.COM*****void CreatePassword() {#define PassWordMax8//将生成密码的最大长度char a[]="0123456789abcdefghijklmnopqrstuvwxyz";//可能的字符long nDictCount=sizeof(a);//获得密码词典长度char cPass[PassWordMax+2];//将生成的密码long nMinL=1,nMaxL=3;//本例中密码长度从1-3long Array[PassWordMax];//密码词典下标ASSERT(nMinL<=nMaxL && nMaxL<=PassWordMax);//容错保证long nLength=nMinL;register long j,i=0;BOOL bNext;CStdioFile file;file.Open("C:\dict.txt",CFile::modeCreateCFile::modeWrite);while(nLength<=nMaxL){for(i=0;i<PassWordMax;i++)Array[i]=0;bNext=TRUE;while(bNext){for(i=0;i<nLength;i++)cPass[i]=a[Array[i]];cPass[i]='</div> <div class="textTags"> <h3>Tags:</h3><span>作者:佚名</span> </div> <div style="clear:both"></div> <div class="mainNewsCount"> [<span id="NewAsp_Hits"><script language="JavaScript" src="/article/hits.asp?id=24632&type=0"></script></span>] [<a href="javascript:history.go(-1)">返回上一页</a>] [<a href="javascript:window.print()">打 印</a>] </div> </div> <script language="javascript" src="/adfile/articlebottom.js"></script> <script type="text/javascript"> <!-- var submitPJend = false; var PJ_CookieName = 'MyPingJia_1_24632'; function submitPingJia(sid,t,m){ if (getCookie(PJ_CookieName)){ alert('友情提示\n\n您已经对此文章进行过评价!'); return; } if(!submitPJend){ var postUrl='/article/ajaxpost.asp?id='+sid+'&t='+t+'&m='+m+'&s=0'; ajaxPostAppraised(postUrl) setCookie(PJ_CookieName,true) }else{ alert('友情提示\n\n你已提交过用户评价,请不要重复提交数据!'); } submitPJend = true; } setTimeout('ajaxPostAppraised("/article/ajaxpost.asp?id=24632&s=1")',1000) //--> </script> <div id="totalscore" style="display:none;">0</div> <ul id="pingjia"> <li><img src="/skins/icons/logo_good.gif" width="33" height="33" /></li> <li class="info"><em>好的评价</em> 如果您觉得此文章好,就请您<br/> <span id="PercentBar1" style="width:1px;"></span>&nbsp;&nbsp;<i><span id="showPercent1">0%</span>(<span id="showscore1">0</span>)</i></li> <li><a href="javascript:"><img onclick="submitPingJia(24632,1,130);" src="/skins/icons/btn_good.gif" width="37" height="39" border="0" /></a></li> <li><img src="/skins/icons/logo_bad.gif" width="33" height="33" /></li> <li class="info"><em>差的评价</em> 如果您觉得此文章差,就请您<br/> <span id="PercentBar2" style="width:1px;" ></span>&nbsp;&nbsp;<i><span id="showPercent2">0%</span>(<span id="showscore2">0</span>)</i></li> <li><a href="javascript:"><img onclick="submitPingJia(24632,0,130);" src="/skins/icons/btn_bad.gif" border="0" /></a></li> </ul> <div style="clear:both;overflow:hidden;font-size:0;line-height:0;"></div> <div class="mainstory"> <div id="mainNextArticle" class="story"> <ul> <li><a onclick='window.open("http://www1.baidu.com/baidu?word=穷举密码算法")' href="javascript:"><img src="/skins/icons/icon_baidu.gif" align="absmiddle" border="0" />中查找“穷举密码算法”更多相关内容</a></li> <li><a onclick='window.open("http://www.google.cn/search?q=穷举密码算法&client=pub-7181357378968076&forid=1&prog=aff&ie=GB2312&oe=GB2312&hl=zh-CN")' href="javascript:"><img src="/skins/icons/icon_google.gif" align="absmiddle" border="0" />中查找“穷举密码算法”更多相关内容</a></li> <li>·上一篇文章:<a href="/article/html/24631.html">优化了的过关键点的光滑曲线拟合算法</a></li> <li>·下一篇文章:<a href="/article/html/24633.html">用Win32 API创建不规则窗口</a></li> </ul> </div> </div> <div class="mainstory"> <h2><span class="boxhead col-icon12">文章评论</span><span class="headLinks"><a href="/article/comment.asp?id=24632">评论内容只代表网友观点,与本站立场无关!</a> <input type="button" name="postBtn2" id="postBtn2" value="发表评论" onclick="showElement('postComment2')" /> </span></h2> <div class="story" style="padding:3px;">&nbsp; &nbsp;评论摘要(共 <font color="red">0</font> 条,得分 <font color="red">0</font> 分,平均 <font color="red">0</font> 分) <a href="/article/comment.asp?id=24632">查看完整评论</a> <hr align="center" width="96%" color="#eeeeee" noShade="noShade" size="1" class="HRcomt" /> </div> </div> <div class="mainstory" id="postComment2" style="display:none;"> <div class="story postComment" style="padding:3px;"> <script type="text/javascript"> <!-- var show_checkcode = false; function get_checkcode() { var chkCodeFile = "/common/getcode.asp"; if(!show_checkcode){ if(document.getElementById("img_checkcode")) document.getElementById("img_checkcode").innerHTML = '<img id="checkcodeimg" src="'+chkCodeFile+'?t='+Math.random()+'" alt="点击刷新验证码" style="cursor:pointer;border:0;vertical-align:middle;height:18px;" onclick="this.src=\''+chkCodeFile+'?t=\'+Math.random()" />' show_checkcode = true; if(document.getElementById("isok_checkcode")) document.getElementById("isok_checkcode").innerHTML = '<a href="javascript://" onclick="setTimeout(function(){ document.getElementById(\'checkcodeimg\').src=\''+chkCodeFile+'?t=\'+Math.random()},100);">看不清<\/a>'; } } //--> </script> <a name="comment"></a><iframe style="display:none;" name="_blankframe"></iframe> <form name="commentform" method="post" action="/common/comment.asp" target="_blankframe"> <input type="hidden" name="postid" value="24632" /> <input type="hidden" name="channelid" value="1" /> <input type="hidden" name="modules" value="1" /> <input type="hidden" name="action" value="save" /> <input type="hidden" name="history" value="1" /> <p>用户名:<input type="text" name="username" maxlength="15" size="28" /> <font color="#ff0000">!</font> <a href="/article/comment.asp?id=24632" target="_blank">查看更多评论</a></p> <p>分 值:<input type="radio" name="grade" value="100" />100分 <input type="radio" name="grade" value="85" checked="true" />85分 <input type="radio" name="grade" value="70" />70分 <input type="radio" name="grade" value="55" />55分 <input type="radio" name="grade" value="40" />40分 <input type="radio" name="grade" value="25" />25分 <input type="radio" name="grade" value="10" />10分 <input type="radio" name="grade" value="1" />1分</p> <p>内 容:<textarea name="content" cols="70" rows="5" title="请注意用语文明且合法,不要发布带有攻击性的言论,谢谢合作!"></textarea> <font color="#ff0000">!</font></p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="submit_button" value="提交" class="button" /> <input type="reset" name="reset_button" value="重设" class="button" /> <font color="#FF0000">通知管理员</font> <input type="checkbox" name="apprize" value="1" /> 验证码:<input name="checkcode" type="text" class="logininput" id="checkcode" size="5" maxlength="4" onfocus="get_checkcode();this.onfocus=null;" onkeyup="ajaxcheckcode('check_code','checkcode');" /> <span id="img_checkcode"><label style="cursor:pointer;" onclick="get_checkcode();">点击获取验证码</label></span><span id="isok_checkcode"></span></p> </form></div> </div> </div><!--End #mainBody --> <div id="leftBody"> <div class="sideContainer"> <h2><span class="boxhead">栏目导航</span></h2> <ul id="leftCatalog"> <li><a href="/article/html/list148-1.html" title="编程其他">编程其他</a></li> <li><a href="/article/html/list147-1.html" title="计算机网络">计算机网络</a></li> <li><a href="/article/html/list146-1.html" title="计算机应用">计算机应用</a></li> <li><a href="/article/html/list145-1.html" title="计算机理论">计算机理论</a></li> <li><a href="/article/html/list179-1.html" title="VisualBasic">VisualBasic</a></li> <li><a href="/article/html/list180-1.html" title="Delphi">Delphi</a></li> <li><a href="/article/html/list181-1.html" title="Visual C++">Visual C++</a></li> <li><a href="/article/html/list182-1.html" title="C++ Builder">C++ Builder</a></li> <li class="finally"></li></ul> </div> <div class="sideContainer"> <h2><span class="boxhead">本类热门阅览</span></h2> <ul class="list-icons"> <li><span class="list-icon1">1</span><a href="/article/html/24724.html" title="虚拟设备驱动程序结构(Vxd教程3)">虚拟设备驱动程序结构(Vxd教程</a></li> <li><span class="list-icon1">2</span><a href="/article/html/24723.html" title="用VC实现动态改变Windows的显示特性">用VC实现动态改变Windows的显</a></li> <li><span class="list-icon1">3</span><a href="/article/html/24722.html" title="编程高手 实例解析C++/CLI之代理与事件">编程高手 实例解析C++/CLI之代</a></li> <li><span class="list-icon2">4</span><a href="/article/html/24721.html" title="用VC实现Windows显示特性的动态改变">用VC实现Windows显示特性的动</a></li> <li><span class="list-icon2">5</span><a href="/article/html/24720.html" title="使用C#开发SmartPhone程序入门">使用C#开发SmartPhone程序入门</a></li> <li><span class="list-icon2">6</span><a href="/article/html/24719.html" title="理解VC# 2005中的字符串和正规表达式">理解VC# 2005中的字符串和正规</a></li> <li><span class="list-icon2">7</span><a href="/article/html/24718.html" title="C++启蒙教程之教你编写简单的C++程序">C++启蒙教程之教你编写简单的</a></li> <li><span class="list-icon2">8</span><a href="/article/html/24717.html" title="用Visual C++干干净净地清除进程">用Visual C++干干净净地清除进</a></li> <li><span class="list-icon2">9</span><a href="/article/html/24716.html" title="利用Visual C#实现任务栏通知窗口">利用Visual C#实现任务栏通知</a></li> <li><span class="list-icon2">10</span><a href="/article/html/24715.html" title="实例解析C++/CLI的串行化">实例解析C++/CLI的串行化</a></li> <li><span class="list-icon2">11</span><a href="/article/html/24714.html" title="用Visual C++设计屏幕抓图程序">用Visual C++设计屏幕抓图程序</a></li> <li><span class="list-icon2">12</span><a href="/article/html/24713.html" title="C++中接口与实现分离的技术">C++中接口与实现分离的技术</a></li> </ul> </div> <div class="sideContainer"> <h2><span class="boxhead">相关文章</span></h2> <ul> <li class="list1"> &rsaquo; <a href="/article/html/24632.html" title="穷举密码算法">穷举密码算法</a></li> </ul> </div> </div><!--End #leftBody --> </div><!-- End #pageMain --> <div class="bottombox"> <div class="bottomadbox"><script language="javascript" src="/adfile/foot.js"></script></div> </div> <div style="clear:both"></div> <div class="bottom"> <div class="bottomArea"> <div class="abc" id="abcbox"><ul> <li class="zimu">按字母检索</li> <li><a href="/article/html/ABC_A_1.html">A</a></li> <li><a href="/article/html/ABC_B_1.html">B</a></li> <li><a href="/article/html/ABC_C_1.html">C</a></li> <li><a href="/article/html/ABC_D_1.html">D</a></li> <li><a href="/article/html/ABC_E_1.html">E</a></li> <li><a href="/article/html/ABC_F_1.html">F</a></li> <li><a href="/article/html/ABC_G_1.html">G</a></li> <li><a href="/article/html/ABC_H_1.html">H</a></li> <li><a href="/article/html/ABC_I_1.html">I</a></li> <li><a href="/article/html/ABC_J_1.html">J</a></li> <li><a href="/article/html/ABC_K_1.html">K</a></li> <li><a href="/article/html/ABC_L_1.html">L</a></li> <li><a href="/article/html/ABC_M_1.html">M</a></li> <li><a href="/article/html/ABC_N_1.html">N</a></li> <li><a href="/article/html/ABC_O_1.html">O</a></li> <li><a href="/article/html/ABC_P_1.html">P</a></li> <li><a href="/article/html/ABC_Q_1.html">Q</a></li> <li><a href="/article/html/ABC_R_1.html">R</a></li> <li><a href="/article/html/ABC_S_1.html">S</a></li> <li><a href="/article/html/ABC_T_1.html">T</a></li> <li><a href="/article/html/ABC_U_1.html">U</a></li> <li><a href="/article/html/ABC_V_1.html">V</a></li> <li><a href="/article/html/ABC_W_1.html">W</a></li> <li><a href="/article/html/ABC_X_1.html">X</a></li> <li><a href="/article/html/ABC_Y_1.html">Y</a></li> <li><a href="/article/html/ABC_Z_1.html">Z</a></li> </ul> <ul> <li class="zimu">按声母检索</li> <li><a href="/article/html/ABC_A-Z_1.html">A</a></li> <li><a href="/article/html/ABC_B-Z_1.html">B</a></li> <li><a href="/article/html/ABC_C-Z_1.html">C</a></li> <li><a href="/article/html/ABC_D-Z_1.html">D</a></li> <li><a href="/article/html/ABC_E-Z_1.html">E</a></li> <li><a href="/article/html/ABC_F-Z_1.html">F</a></li> <li><a href="/article/html/ABC_G-Z_1.html">G</a></li> <li><a href="/article/html/ABC_H-Z_1.html">H</a></li> <li><a href="/article/html/ABC_J-Z_1.html">J</a></li> <li><a href="/article/html/ABC_K-Z_1.html">K</a></li> <li><a href="/article/html/ABC_L-Z_1.html">L</a></li> <li><a href="/article/html/ABC_M-Z_1.html">M</a></li> <li><a href="/article/html/ABC_N-Z_1.html">N</a></li> <li><a href="/article/html/ABC_O-Z_1.html">O</a></li> <li><a href="/article/html/ABC_P-Z_1.html">P</a></li> <li><a href="/article/html/ABC_Q-Z_1.html">Q</a></li> <li><a href="/article/html/ABC_R-Z_1.html">R</a></li> <li><a href="/article/html/ABC_S-Z_1.html">S</a></li> <li><a href="/article/html/ABC_T-Z_1.html">T</a></li> <li><a href="/article/html/ABC_W-Z_1.html">W</a></li> <li><a href="/article/html/ABC_X-Z_1.html">X</a></li> <li><a href="/article/html/ABC_Y-Z_1.html">Y</a></li> <li><a href="/article/html/ABC_Z-Z_1.html">Z</a></li> <li class="shuzi"><a href="/article/html/ABC_0-9_1.html">数字</a></li> <li class="shuzi"><a href="/article/html/ABC_A-9_1.html">符号</a></li> </ul> </div> <span></span> <div class="bottomText"> <a href="/support/about.asp">关于本站</a> | <a href="/support/help.asp">网站帮助</a> | <a href="/support/advertise.asp">广告合作</a> | <a href="/support/declare.asp">下载声明</a> | <a href="/link/" target="_blank">友情连接</a> | <a href="/sitemap.html">网站地图</a><br/> </div> <div class="bottomLogo"></div> <font color=blue>PB创新网</font>【<a href="http://www.ourmis.com" target="_blank"><font face="Verdana, Arial, Helvetica, sans-serif"><b>ourmis<font color="#CC0000">.com</font></b></font></a>】Copyright &copy; 2000-2009 . All Rights Reserved .<br/>页面执行时间:14,625.00000 毫秒<br/>Email:<a href="mailto:ourmis@126.com" target="_blank" class="navmenu">ourmis@126.com</a> QQ:<a href="tencent://message/?uin=2322888&Site=www.ourmis.com&Menu=yes" target="blank"><font color=red>2322888</font></a> <script src="/js/footer.js" type="text/javascript"></script> <a href="http://www.miibeian.gov.cn/" target="_blank" title="查询备案信息">蜀ICP备05006790号</a> <script src='http://s74.cnzz.com/stat.php?id=383295&web_id=383295&show=pic' language='JavaScript' charset='gb2312'></script> </div> <div class="bottom2"></div> </div> </body> </html>