import{_ as e,c as m,a as n,e as l,b as s,r as p,o as i}from"./app-COnnofor.js";const r={};function c(o,a){const t=p("Mermaid");return i(),m("div",null,[a[0]||(a[0]=n('

1. 密码学的定义

1.1 基本概念

密码学(Cryptography) 是一门研究信息安全的学科,主要关注如何在不安全的环境中实现安全通信。其核心是通过数学方法对信息进行变换,使得只有授权方能够理解信息内容。

1.2 核心目标

密码学追求以下四个主要安全目标:

1.3 重要作用

密码学在现代信息安全中扮演着至关重要的角色:

1.4 主要应用场景

1.5 基础概念与术语(入门)

为方便初学者快速建立直觉,先认识密码学中最核心的几个概念:

明文(Plaintext)与密文(Ciphertext)

加密(Encryption)与解密(Decryption)

C=Ek(P)C = E_k(P)

P=Dk(C)P = D_k(C)

其中,PP 表示明文,CC 表示密文,kk 表示密钥,EE 为加密算法,DD 为解密算法。

密钥(Key):对称密钥 vs 非对称密钥

对称加密流程示意(同一把密钥):

',24)),l(t,{code:"eJxLy8kvT85ILCpR8AniUlAIjn7aP/FlQ+OLhtZYBV1dhSd79z+fsuJp68Ynu1Y/Xd/2ctJSBW+Fp10LgGygtJ2Cc7QGkPlsWrtmLFC3M04tL5YvhmkJin7Wt/TZlG0gK7gAfgE/qw=="}),a[1]||(a[1]=s("p",null,"非对称加密流程示意(公钥/私钥):",-1)),l(t,{code:"eJxLy8kvT85ILCpR8AniUlAIjn7aP/FlQ+OLhtZYBV1dhSd79z+fsuJZ39JnU7YBxZ62rnk5aenTrgVP17cBpe0UnKM1gMxn09o1Y4G6nbFoeb68EajlxfLFMC1B0XC5WC4A+5BCKg=="}),a[2]||(a[2]=s("p",null,"在典型的 RSA 公钥体制中,还可以用一个简洁的数学表达式表示加解密:",-1)),a[3]||(a[3]=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mtable",{rowspacing:"0.25em",columnalign:"right left",columnspacing:"0em"},[s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mi",null,"c")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mo",null,"="),s("msup",null,[s("mi",null,"m"),s("mi",null,"e")]),s("mtext",null," "),s("mo",{lspace:"0.22em",rspace:"0.22em"},[s("mrow",null,[s("mi",{mathvariant:"normal"},"m"),s("mi",{mathvariant:"normal"},"o"),s("mi",{mathvariant:"normal"},"d")])]),s("mtext",null," "),s("mi",null,"n"),s("mo",{separator:"true"},",")])])])]),s("mtr",null,[s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mi",null,"m")])]),s("mtd",null,[s("mstyle",{scriptlevel:"0",displaystyle:"true"},[s("mrow",null,[s("mrow"),s("mo",null,"="),s("msup",null,[s("mi",null,"c"),s("mi",null,"d")]),s("mtext",null," "),s("mo",{lspace:"0.22em",rspace:"0.22em"},[s("mrow",null,[s("mi",{mathvariant:"normal"},"m"),s("mi",{mathvariant:"normal"},"o"),s("mi",{mathvariant:"normal"},"d")])]),s("mtext",null," "),s("mi",null,"n"),s("mo",{separator:"true"},",")])])])])]),s("annotation",{encoding:"application/x-tex"},"\\begin{aligned} c &= m^{e} \\bmod n,\\\\ m &= c^{d} \\bmod n, \\end{aligned} ")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"3.0591em","vertical-align":"-1.2796em"}}),s("span",{class:"mord"},[s("span",{class:"mtable"},[s("span",{class:"col-align-r"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.7796em"}},[s("span",{style:{top:"-3.9396em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"c")])]),s("span",{style:{top:"-2.3804em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"m")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.2796em"}},[s("span")])])])]),s("span",{class:"col-align-l"},[s("span",{class:"vlist-t vlist-t2"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.7796em"}},[s("span",{style:{top:"-3.9396em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"m"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7144em"}},[s("span",{style:{top:"-3.113em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mathnormal mtight"},"e")])])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.0556em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},[s("span",{class:"mord"},[s("span",{class:"mord mathrm"},"mod")])]),s("span",{class:"mspace",style:{"margin-right":"0.0556em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mpunct"},",")])]),s("span",{style:{top:"-2.3804em"}},[s("span",{class:"pstrut",style:{height:"3em"}}),s("span",{class:"mord"},[s("span",{class:"mord"}),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"c"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8991em"}},[s("span",{style:{top:"-3.113em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mathnormal mtight"},"d")])])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.0556em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},[s("span",{class:"mord"},[s("span",{class:"mord mathrm"},"mod")])]),s("span",{class:"mspace",style:{"margin-right":"0.0556em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mpunct"},",")])])]),s("span",{class:"vlist-s"},"​")]),s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"1.2796em"}},[s("span")])])])])])])])])])])],-1)),a[4]||(a[4]=n('

其中 (e,n)(e, n) 为公钥,(d,n)(d, n) 为私钥,mm 为明文,cc 为密文。

常见攻击模型简介(只需直观理解)

直观结论:设计良好的现代密码系统,应当在这些攻击模型下仍保持安全(在合理的参数与假设下)。

2. 密码学历史简述

2.1 古代密码学(公元前-15世纪)

凯撒密码(Caesar Cipher)

斯巴达密码棒(Scytale)

古典密码简述:

2.2 文艺复兴时期(15-18世纪)

维吉尼亚密码(Vigenère Cipher)

博福特密码(Beaufort Cipher)

2.3 近代密码学(19-20世纪中期)

恩尼格玛密码机(Enigma)

香农的信息论

2.4 现代密码学(1970年代至今)

DES算法

RSA算法

AES算法

现代密码简述:

C=Ek(P),P=Dk(C)C = E_k(P), \\quad P = D_k(C)

',33)),a[5]||(a[5]=s("p",{class:"katex-block"},[s("span",{class:"katex-display"},[s("span",{class:"katex"},[s("span",{class:"katex-mathml"},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("semantics",null,[s("mrow",null,[s("mi",null,"c"),s("mo",null,"="),s("msup",null,[s("mi",null,"m"),s("mi",null,"e")]),s("mtext",null," "),s("mo",{lspace:"0.22em",rspace:"0.22em"},[s("mrow",null,[s("mi",{mathvariant:"normal"},"m"),s("mi",{mathvariant:"normal"},"o"),s("mi",{mathvariant:"normal"},"d")])]),s("mtext",null," "),s("mi",null,"n"),s("mo",{separator:"true"},","),s("mspace",{width:"1em"}),s("mi",null,"m"),s("mo",null,"="),s("msup",null,[s("mi",null,"c"),s("mi",null,"d")]),s("mtext",null," "),s("mo",{lspace:"0.22em",rspace:"0.22em"},[s("mrow",null,[s("mi",{mathvariant:"normal"},"m"),s("mi",{mathvariant:"normal"},"o"),s("mi",{mathvariant:"normal"},"d")])]),s("mtext",null," "),s("mi",null,"n")]),s("annotation",{encoding:"application/x-tex"},"c = m^{e} \\bmod n, \\quad m = c^{d} \\bmod n ")])])]),s("span",{class:"katex-html","aria-hidden":"true"},[s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"c"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.7144em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"m"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.7144em"}},[s("span",{style:{top:"-3.113em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mathnormal mtight"},"e")])])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.0556em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},[s("span",{class:"mord"},[s("span",{class:"mord mathrm"},"mod")])]),s("span",{class:"mspace",style:{"margin-right":"0.0556em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.625em","vertical-align":"-0.1944em"}}),s("span",{class:"mord mathnormal"},"n"),s("span",{class:"mpunct"},","),s("span",{class:"mspace",style:{"margin-right":"1em"}}),s("span",{class:"mspace",style:{"margin-right":"0.1667em"}}),s("span",{class:"mord mathnormal"},"m"),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}}),s("span",{class:"mrel"},"="),s("span",{class:"mspace",style:{"margin-right":"0.2778em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.8991em"}}),s("span",{class:"mord"},[s("span",{class:"mord mathnormal"},"c"),s("span",{class:"msupsub"},[s("span",{class:"vlist-t"},[s("span",{class:"vlist-r"},[s("span",{class:"vlist",style:{height:"0.8991em"}},[s("span",{style:{top:"-3.113em","margin-right":"0.05em"}},[s("span",{class:"pstrut",style:{height:"2.7em"}}),s("span",{class:"sizing reset-size6 size3 mtight"},[s("span",{class:"mord mtight"},[s("span",{class:"mord mathnormal mtight"},"d")])])])])])])])]),s("span",{class:"mspace",style:{"margin-right":"0.0556em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}}),s("span",{class:"mbin"},[s("span",{class:"mord"},[s("span",{class:"mord mathrm"},"mod")])]),s("span",{class:"mspace",style:{"margin-right":"0.0556em"}}),s("span",{class:"mspace",style:{"margin-right":"0.2222em"}})]),s("span",{class:"base"},[s("span",{class:"strut",style:{height:"0.4306em"}}),s("span",{class:"mord mathnormal"},"n")])])])])],-1)),a[6]||(a[6]=n(`

2.5 关键历史时间线

公元前5世纪:斯巴达密码棒
公元前1世纪:凯撒密码
16世纪:维吉尼亚密码
1918年:一次一密密码本
1949年:香农信息论
1977年:DES和RSA算法
2001年:AES标准

总结

密码学作为信息安全的基石,经历了从简单替换到复杂数学算法的漫长发展历程。现代密码学建立在严格的数学基础之上,通过对称加密、非对称加密等多种技术手段,为数字世界提供了可靠的安全保障。

理解密码学的基本原理和分类,有助于我们更好地应用这些技术来保护信息安全,同时也为深入学习更高级的密码学概念奠定基础。

本篇笔记的所有代码开源于:https://gitea.simengweb.com/si-meng-spec/cryptography-example-code

`,7))])}const g=e(r,[["render",c]]),d=JSON.parse('{"path":"/theory/cryptography/","title":"密码学基础","lang":"zh-CN","frontmatter":{"title":"密码学基础","createTime":"2025/10/27 10:38:57","permalink":"/theory/cryptography/","description":"1. 密码学的定义 1.1 基本概念 密码学(Cryptography) 是一门研究信息安全的学科,主要关注如何在不安全的环境中实现安全通信。其核心是通过数学方法对信息进行变换,使得只有授权方能够理解信息内容。 1.2 核心目标 密码学追求以下四个主要安全目标: 机密性(Confidentiality):确保信息只能被授权的人访问 完整性(Integr...","head":[["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"密码学基础\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2025-10-29T05:45:37.000Z\\",\\"author\\":[]}"],["meta",{"property":"og:url","content":"https://notes.simengweb.com/theory/cryptography/"}],["meta",{"property":"og:site_name","content":"仲夏夜之梦"}],["meta",{"property":"og:title","content":"密码学基础"}],["meta",{"property":"og:description","content":"1. 密码学的定义 1.1 基本概念 密码学(Cryptography) 是一门研究信息安全的学科,主要关注如何在不安全的环境中实现安全通信。其核心是通过数学方法对信息进行变换,使得只有授权方能够理解信息内容。 1.2 核心目标 密码学追求以下四个主要安全目标: 机密性(Confidentiality):确保信息只能被授权的人访问 完整性(Integr..."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:updated_time","content":"2025-10-29T05:45:37.000Z"}],["meta",{"property":"article:modified_time","content":"2025-10-29T05:45:37.000Z"}]]},"readingTime":{"minutes":5.34,"words":1603},"git":{"createdTime":1761564580000,"updatedTime":1761716737000,"contributors":[{"name":"祀梦","username":"","email":"3501646051@qq.com","commits":2,"avatar":"https://gravatar.com/avatar/6406a81eeddc359cf3d3ce018797689fc6d014ff06215c27d0210b42e8f5a8ab?d=retro"}]},"autoDesc":true,"filePathRelative":"notes/theory/cryptography/README.md","headers":[]}');export{g as comp,d as data};