电脑教程中文网
首页  动态网站建设学习 程序  笑话  论坛 娱乐  交友 ADSL  峄城  成功者
中文名:电脑教程中文网,收集了大量的电脑教程! 编程技术文档 游戏开发 笑话站暂时关闭 设为首页
网页设计 HTML | Dreamweaver | CSS | Firework | FrontPage WEB开发 ASP | JSP | PHP | .NET | CGI | JS | VBS | XML | IIS6 | Apache | PWS
程序设计 Java | C++ |VC++ | C# | Delphi | VB | C语言 | 汇编 | Pascal | Perl 数据库 MSSQL | MySQL | Access | VF | Oracle | DB2 | SYBASE |
办公软件 Word | Excel | WPS | PowerPoint 动画平面 Photoshop | ACDSee | 3Dmax | Flash | Coreldraw |
操作系统 Windows 2000 | Windows XP | Windows 2003 | SCO Unix | Windows Vista | unix、Linux | 综合| 服务器 | 系统安全| 黑客技术
其  他 UltraDev | DOS | UML | PWS | Powerbuilder | 开发心得 | 设计理念 | 病毒库 | 其他 | LightTPD (分类排序给您带来不便请谅解)
推  荐: Java文档500篇》《ASP.NET与相关数据库技术高级指南》《TC图形函数详解》《C函数速查手册》《C语言编程宝典之一》《MFC深入浅出》《黑客零起点》《VC++ 编程指南》《JScript 用户指南》 《CSS教程宝典》《Microsoft Jet SQL 参考》《delphi技巧集合》《MySQL 4.1.0 中文参考手册》《MySQL中文手册
【导航】 您现在的位置 : 首页 - .NET教程 - 《.NET技术文档0802期》- 2008脚本大赛PowerShell高级组Event 5解题及分析

2008脚本大赛PowerShell高级组Event 5解题及分析

日期:2008-2-28 21:44:39 作者:Edengundam 人气:     来源:网络




题目位置: http://www.microsoft.com/technet/scriptcenter/funzone/games/games08/chs/aevent5.mspx

官方题目解答: http://www.microsoft.com/technet/scriptcenter/funzone/games/solutions08/expssol05.mspx

这题确实没有什么可以讲的, 主要是利用hash表来确定密码是否是单词. 我的第13个检查就是把字符串变成数组, 利用hash表来看每一个字符出现了几次, 如果是第二次出现, ?{} 就会为真, 改对象就会沿着管道进入到%{$dup = $true}中, 也就标记了该密码有重复字符.

param([string]$password)
$script:score = 13;
$rating = "weak","weak","weak","weak","weak","weak","weak",`
"moderately-strong","moderately-strong","moderately-strong","moderately-strong",`
"strong", "strong", "strong"
# 0: prepare ...
$hash = @{}
$chars = @{}
$dup = $false
Get-Content -Path C:Scriptswordlist.txt | % { $hash[$_] = $null }
# 1
if ($hash.ContainsKey($password)) {$script:score--; "Password is an actual word"}
# 2
if ($hash.ContainsKey($password.Remove($password.Length-1,1))) {$script:score--; "Password, minus the last letter, is an actual word."}
# 3
if ($hash.ContainsKey($password.Remove(0,1))) {$script:score--; "Password, minus the first letter, is an actual word."}
# 4
if ($hash.ContainsKey(($password -match '0') -and ($password -replace '0','o'))) {$script:score--; "Password simply substitute 0 (zero) for the letter o."}
# 5
if ($hash.ContainsKey(($password -match '1') -and ($password -replace '1','l'))) {$script:score--; "Password simply substitute 1 (one) for the letter l."}
# 6
if ($password.Length -lt 10) {$script:score--; "password is less than 10 characters"}
if ($password.Length -gt 20) {$script:score--; "password is more than 20 characters"}
# 7
if ($password -notmatch 'd') {$script:score--; "No number in password."}
# 8
if ($password -cnotmatch '[A-Z]') {$script:score--; "No uppercase letter in password."}
# 9
if ($password -cnotmatch '[a-z]') {$script:score--; "No lowercase letter in password."}
# 10
if ($password -cnotmatch '[^0-9a-zA-Z]') {$script:score--; "No symbol in password."}
#11
if ($password -cmatch '[a-z]{4,}') {$script:score--; "Four or more consecutive lowercase letters in password."}
#12
if ($password -cmatch '[A-Z]{4,}') {$script:score--; "Four or more consecutive uppercase letters in password."}
#13
$password.ToCharArray() | ? { [bool] $chars["$_"]++ } | % {$dup = $true}
if ($dup) {$script:score--; "Duplicate letters in password.";}
# result
""
"A password score of $script:score indicates a $($rating[$script:score]) password."



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=2129252


转自CLDE.NET


本文由CLDE.NET原创或整理(收集),如您需转载,请保留一下链接,谢谢!


下一篇:汉字转换成拼音,拼音转换成汉字,字母边界之间汉字,取汉字拼音首字母的存储过程
※视频教程※
ASP入门到精通视频教程
西安电科大JSP视频教程
photoshop cs2视频教程
flash动画设计师视频教程
Dreamweaver视频教程
VB从入门到精通视频教程
 
 


网站首页 - 友情链接 - 公司简介 - 联系方式 - 广告投放 - 客户服务 - 错误报告 - 免责声明 - About us
CLDE.NET电脑教程中文网版权所有 未经许可禁止镜象和复制本站资料 MSN:CLDE_NET@hotmail.com
技术支持:CLDE.NET信息中心 鲁ICP备05039940号 友情链接QQ:784079(隐)