Passwords and authentication
证明你是你
- **身份验证(authentication)**就是证明你确实是你所声称的那个人。经典的方式有三种:
- 你知道的东西(密码)、你拥有的东西(手机)、你本身的特征(指纹)。
更强的登录
- 生物识别(biometrics) —— 指纹或人脸扫描;难以盗取,但并非完美。
- 双因素认证 (2FA) — 密码 加上 来自手机的一次性代码。
- 仅被盗的密码便不再足以登录。2FA 并非完美无缺:伪造的登录页面也可能要求输入验证码,因此仍需核实网址。
什么样的密码才算强?
- 长度胜过一切。 每多一个字符,都会把攻击者所需的猜测次数成倍放大。
- 字母、数字和符号混用会有帮助 —— 但像
correct horse battery staple这样的长口令,既强又好记。
写一个检查器
- 下面,写一条小规则:只有当密码足够长并且含有数字时,才算 “strong”。
- 真实的检查器还会拒绝像
123456和password这样的常见密码。
涵盖:IGCSE 5.3(身份验证)、A-Level 6.1、AP CSP Big Idea 5。
常见错误
- 又长又独特胜过又短又复杂却重复使用。
- 双因素认证增加了第二种不同的验证。
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
Write a simple strength checker. A password is strong if it is at least 8 characters AND contains a digit; otherwise weak. Print the right word for the given password.
点击“运行”查看此处输出。
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
Real checkers also reject common passwords. Improve the rule: if the password is in the common list it is weak no matter what; otherwise apply the old rule (length ≥ 8 AND a digit). Print the verdict.
点击“运行”查看此处输出。
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
A helpful checker says 什么 is missing. Write missing(password), which returns a list of the failed rules, in this order: "length" (fewer than 8 characters), "digit" (no digit), "upper" (no capital letter). A password that passes every rule gives [].
点击“运行”查看此处输出。