SHA1

mac2024-04-06  33

一、概览图:

#mermaid-svg-SRj5dyVG1YR4n6h8 .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 .label text{fill:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 .node rect,#mermaid-svg-SRj5dyVG1YR4n6h8 .node circle,#mermaid-svg-SRj5dyVG1YR4n6h8 .node ellipse,#mermaid-svg-SRj5dyVG1YR4n6h8 .node polygon,#mermaid-svg-SRj5dyVG1YR4n6h8 .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-SRj5dyVG1YR4n6h8 .node .label{text-align:center;fill:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 .node.clickable{cursor:pointer}#mermaid-svg-SRj5dyVG1YR4n6h8 .arrowheadPath{fill:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-SRj5dyVG1YR4n6h8 .flowchart-link{stroke:#333;fill:none}#mermaid-svg-SRj5dyVG1YR4n6h8 .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-SRj5dyVG1YR4n6h8 .edgeLabel rect{opacity:0.9}#mermaid-svg-SRj5dyVG1YR4n6h8 .edgeLabel span{color:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-SRj5dyVG1YR4n6h8 .cluster text{fill:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-SRj5dyVG1YR4n6h8 .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-SRj5dyVG1YR4n6h8 text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-SRj5dyVG1YR4n6h8 .actor-line{stroke:grey}#mermaid-svg-SRj5dyVG1YR4n6h8 .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 .sequenceNumber{fill:#fff}#mermaid-svg-SRj5dyVG1YR4n6h8 #sequencenumber{fill:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 #crosshead path{fill:#333;stroke:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 .messageText{fill:#333;stroke:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-SRj5dyVG1YR4n6h8 .labelText,#mermaid-svg-SRj5dyVG1YR4n6h8 .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-SRj5dyVG1YR4n6h8 .loopText,#mermaid-svg-SRj5dyVG1YR4n6h8 .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-SRj5dyVG1YR4n6h8 .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-SRj5dyVG1YR4n6h8 .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-SRj5dyVG1YR4n6h8 .noteText,#mermaid-svg-SRj5dyVG1YR4n6h8 .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-SRj5dyVG1YR4n6h8 .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-SRj5dyVG1YR4n6h8 .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-SRj5dyVG1YR4n6h8 .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-SRj5dyVG1YR4n6h8 .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-SRj5dyVG1YR4n6h8 .section{stroke:none;opacity:0.2}#mermaid-svg-SRj5dyVG1YR4n6h8 .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-SRj5dyVG1YR4n6h8 .section2{fill:#fff400}#mermaid-svg-SRj5dyVG1YR4n6h8 .section1,#mermaid-svg-SRj5dyVG1YR4n6h8 .section3{fill:#fff;opacity:0.2}#mermaid-svg-SRj5dyVG1YR4n6h8 .sectionTitle0{fill:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 .sectionTitle1{fill:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 .sectionTitle2{fill:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 .sectionTitle3{fill:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-SRj5dyVG1YR4n6h8 .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-SRj5dyVG1YR4n6h8 .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-SRj5dyVG1YR4n6h8 .grid path{stroke-width:0}#mermaid-svg-SRj5dyVG1YR4n6h8 .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-SRj5dyVG1YR4n6h8 .task{stroke-width:2}#mermaid-svg-SRj5dyVG1YR4n6h8 .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-SRj5dyVG1YR4n6h8 .taskText:not([font-size]){font-size:11px}#mermaid-svg-SRj5dyVG1YR4n6h8 .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-SRj5dyVG1YR4n6h8 .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-SRj5dyVG1YR4n6h8 .task.clickable{cursor:pointer}#mermaid-svg-SRj5dyVG1YR4n6h8 .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-SRj5dyVG1YR4n6h8 .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-SRj5dyVG1YR4n6h8 .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-SRj5dyVG1YR4n6h8 .taskText0,#mermaid-svg-SRj5dyVG1YR4n6h8 .taskText1,#mermaid-svg-SRj5dyVG1YR4n6h8 .taskText2,#mermaid-svg-SRj5dyVG1YR4n6h8 .taskText3{fill:#fff}#mermaid-svg-SRj5dyVG1YR4n6h8 .task0,#mermaid-svg-SRj5dyVG1YR4n6h8 .task1,#mermaid-svg-SRj5dyVG1YR4n6h8 .task2,#mermaid-svg-SRj5dyVG1YR4n6h8 .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-SRj5dyVG1YR4n6h8 .taskTextOutside0,#mermaid-svg-SRj5dyVG1YR4n6h8 .taskTextOutside2{fill:#000}#mermaid-svg-SRj5dyVG1YR4n6h8 .taskTextOutside1,#mermaid-svg-SRj5dyVG1YR4n6h8 .taskTextOutside3{fill:#000}#mermaid-svg-SRj5dyVG1YR4n6h8 .active0,#mermaid-svg-SRj5dyVG1YR4n6h8 .active1,#mermaid-svg-SRj5dyVG1YR4n6h8 .active2,#mermaid-svg-SRj5dyVG1YR4n6h8 .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-SRj5dyVG1YR4n6h8 .activeText0,#mermaid-svg-SRj5dyVG1YR4n6h8 .activeText1,#mermaid-svg-SRj5dyVG1YR4n6h8 .activeText2,#mermaid-svg-SRj5dyVG1YR4n6h8 .activeText3{fill:#000 !important}#mermaid-svg-SRj5dyVG1YR4n6h8 .done0,#mermaid-svg-SRj5dyVG1YR4n6h8 .done1,#mermaid-svg-SRj5dyVG1YR4n6h8 .done2,#mermaid-svg-SRj5dyVG1YR4n6h8 .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-SRj5dyVG1YR4n6h8 .doneText0,#mermaid-svg-SRj5dyVG1YR4n6h8 .doneText1,#mermaid-svg-SRj5dyVG1YR4n6h8 .doneText2,#mermaid-svg-SRj5dyVG1YR4n6h8 .doneText3{fill:#000 !important}#mermaid-svg-SRj5dyVG1YR4n6h8 .crit0,#mermaid-svg-SRj5dyVG1YR4n6h8 .crit1,#mermaid-svg-SRj5dyVG1YR4n6h8 .crit2,#mermaid-svg-SRj5dyVG1YR4n6h8 .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-SRj5dyVG1YR4n6h8 .activeCrit0,#mermaid-svg-SRj5dyVG1YR4n6h8 .activeCrit1,#mermaid-svg-SRj5dyVG1YR4n6h8 .activeCrit2,#mermaid-svg-SRj5dyVG1YR4n6h8 .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-SRj5dyVG1YR4n6h8 .doneCrit0,#mermaid-svg-SRj5dyVG1YR4n6h8 .doneCrit1,#mermaid-svg-SRj5dyVG1YR4n6h8 .doneCrit2,#mermaid-svg-SRj5dyVG1YR4n6h8 .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-SRj5dyVG1YR4n6h8 .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-SRj5dyVG1YR4n6h8 .milestoneText{font-style:italic}#mermaid-svg-SRj5dyVG1YR4n6h8 .doneCritText0,#mermaid-svg-SRj5dyVG1YR4n6h8 .doneCritText1,#mermaid-svg-SRj5dyVG1YR4n6h8 .doneCritText2,#mermaid-svg-SRj5dyVG1YR4n6h8 .doneCritText3{fill:#000 !important}#mermaid-svg-SRj5dyVG1YR4n6h8 .activeCritText0,#mermaid-svg-SRj5dyVG1YR4n6h8 .activeCritText1,#mermaid-svg-SRj5dyVG1YR4n6h8 .activeCritText2,#mermaid-svg-SRj5dyVG1YR4n6h8 .activeCritText3{fill:#000 !important}#mermaid-svg-SRj5dyVG1YR4n6h8 .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-SRj5dyVG1YR4n6h8 g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-SRj5dyVG1YR4n6h8 g.classGroup text .title{font-weight:bolder}#mermaid-svg-SRj5dyVG1YR4n6h8 g.clickable{cursor:pointer}#mermaid-svg-SRj5dyVG1YR4n6h8 g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-SRj5dyVG1YR4n6h8 g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-SRj5dyVG1YR4n6h8 .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-SRj5dyVG1YR4n6h8 .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-SRj5dyVG1YR4n6h8 .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-SRj5dyVG1YR4n6h8 .dashed-line{stroke-dasharray:3}#mermaid-svg-SRj5dyVG1YR4n6h8 #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-SRj5dyVG1YR4n6h8 #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-SRj5dyVG1YR4n6h8 #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-SRj5dyVG1YR4n6h8 #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-SRj5dyVG1YR4n6h8 #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-SRj5dyVG1YR4n6h8 #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-SRj5dyVG1YR4n6h8 #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-SRj5dyVG1YR4n6h8 #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-SRj5dyVG1YR4n6h8 .commit-id,#mermaid-svg-SRj5dyVG1YR4n6h8 .commit-msg,#mermaid-svg-SRj5dyVG1YR4n6h8 .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-SRj5dyVG1YR4n6h8 .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-SRj5dyVG1YR4n6h8 .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-SRj5dyVG1YR4n6h8 g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-SRj5dyVG1YR4n6h8 g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-SRj5dyVG1YR4n6h8 g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-SRj5dyVG1YR4n6h8 g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-SRj5dyVG1YR4n6h8 g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-SRj5dyVG1YR4n6h8 .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-SRj5dyVG1YR4n6h8 .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-SRj5dyVG1YR4n6h8 .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-SRj5dyVG1YR4n6h8 .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-SRj5dyVG1YR4n6h8 .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-SRj5dyVG1YR4n6h8 .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-SRj5dyVG1YR4n6h8 .edgeLabel text{fill:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-SRj5dyVG1YR4n6h8 .node circle.state-start{fill:black;stroke:black}#mermaid-svg-SRj5dyVG1YR4n6h8 .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-SRj5dyVG1YR4n6h8 #statediagram-barbEnd{fill:#9370db}#mermaid-svg-SRj5dyVG1YR4n6h8 .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-SRj5dyVG1YR4n6h8 .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-SRj5dyVG1YR4n6h8 .statediagram-state .divider{stroke:#9370db}#mermaid-svg-SRj5dyVG1YR4n6h8 .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-SRj5dyVG1YR4n6h8 .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-SRj5dyVG1YR4n6h8 .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-SRj5dyVG1YR4n6h8 .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-SRj5dyVG1YR4n6h8 .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-SRj5dyVG1YR4n6h8 .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-SRj5dyVG1YR4n6h8 .note-edge{stroke-dasharray:5}#mermaid-svg-SRj5dyVG1YR4n6h8 .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-SRj5dyVG1YR4n6h8 .error-icon{fill:#522}#mermaid-svg-SRj5dyVG1YR4n6h8 .error-text{fill:#522;stroke:#522}#mermaid-svg-SRj5dyVG1YR4n6h8 .edge-thickness-normal{stroke-width:2px}#mermaid-svg-SRj5dyVG1YR4n6h8 .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-SRj5dyVG1YR4n6h8 .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-SRj5dyVG1YR4n6h8 .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-SRj5dyVG1YR4n6h8 .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-SRj5dyVG1YR4n6h8 .marker{fill:#333}#mermaid-svg-SRj5dyVG1YR4n6h8 .marker.cross{stroke:#333} :root { --mermaid-font-family: "trebuchet ms", verdana, arial;} #mermaid-svg-SRj5dyVG1YR4n6h8 { color: rgba(0, 0, 0, 0.75); font: ; } 输入数据 格式化输入 补位 附加长度信息 分组格式化 最后一组 格式化输出 输出摘要 是第一组 赋初值 对当前组做单次运算 记录单组结果 取单组结果作为初始值

二、分步解析

1.格式化输入

    因为SHA1算法只接受位作为输入,所以进行计算前必须把原始消息(比如字符串、文件等)转换成位字符串。比如,对字符串“abc”产生消息摘要,‘a’=97 ‘b’=98 ‘c’=99,先转换成24位的字符串(实际上在嵌入式c中不需要转换):     01100001 01100010 01100011。

2.补位

    消息必须进行补位,使其长度在对512取模以后的余数是448,即(补位后的消息长度)%512 = 448。     对消息进行补位时,先在后面补一个1,如果不满足要求,再补0直到满足对512取模余数为448。这就意味着,补位至少补一位(原消息位数为512N+447),最多补512位(原消息位数为512N+448)。     还是以前面的“abc”为例显示补位的过程:     原始信息:         01100001 01100010 01100011     补位第一步,首先补一个1:         01100001 01100010 01100011 1     可以确定的是,如果用一个字节来表示一个字符,补1之后肯定不满足条件,仍需继续补位。     补位第二步,后面补0直到总长度对512取模余数为448,这里补423个0,使总长度达到为448:         01100001 01100010 01100011 1000……00     补位完成后的数据转换为16进制:         61626380 00000000 00000000 00000000         00000000 00000000 00000000 00000000         00000000 00000000 00000000 00000000         00000000 00000000     从16进制数据里可以看到,我们也可以直接采用16进制的方式进行补位(原理是一致的,只不过是进制不同),我们先补80,看是否满足长度对64取余的结果为56,不满足则继续补0。

3.附加长度信息

    这一步中,要将原始消息(没有进行补位操作之前)的长度(二进制位数)附加到已经补位的消息之后。     通常用一个64位的数据来表示原始消息的长度。如果消息长度不大于2^64,那么第一个字就是0。     补长度的操作以后,整个消息(16进制)如下:         61626380 00000000 00000000 00000000         00000000 00000000 00000000 00000000         00000000 00000000 00000000 00000000         00000000 00000000 00000000 00000018     注意,这里是64位,上一步补位后的长度是512N+448,这样,512N+448+64=512(N+1),恰好可以被512整除。

4.分组格式化

    1).将整个消息Z拆分为N个512位的数据块Y1,Y2,…,Yn;     2).将每一块数据Yn进行拆分,拆分成16个32位的字M[k](k= 0, 1,……15)     3).对每一块数据Yn进行扩充运算,得到N个扩充后的数据块X1,X2,……Xn,Xn的格式为:W[k](k= 0, 1,……79);     其中扩充算法如下:         W t = M t , 当0≤t≤15         W t = ( W t-3 ^ W t-8^ W t-14^ W t-16 ) << 1, 当16≤t≤79     实际代码实现过程中,分组格化工作可以在计算到对应数据块时再进行,这样可以节省内存空间。

5.准备初始值

    第一组即X0的W0计算前需要进行初始化,初始化方法如下:         H0 = 0x67452301;         H1 = 0xEFCDAB89;         H2 = 0x98BADCFE;         H3 = 0x10325476;         H4 = 0xC3D2E1F0;

6.单组运算如图:

#mermaid-svg-FwSs9jdpVG100LWR .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-FwSs9jdpVG100LWR .label text{fill:#333}#mermaid-svg-FwSs9jdpVG100LWR .node rect,#mermaid-svg-FwSs9jdpVG100LWR .node circle,#mermaid-svg-FwSs9jdpVG100LWR .node ellipse,#mermaid-svg-FwSs9jdpVG100LWR .node polygon,#mermaid-svg-FwSs9jdpVG100LWR .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-FwSs9jdpVG100LWR .node .label{text-align:center;fill:#333}#mermaid-svg-FwSs9jdpVG100LWR .node.clickable{cursor:pointer}#mermaid-svg-FwSs9jdpVG100LWR .arrowheadPath{fill:#333}#mermaid-svg-FwSs9jdpVG100LWR .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-FwSs9jdpVG100LWR .flowchart-link{stroke:#333;fill:none}#mermaid-svg-FwSs9jdpVG100LWR .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-FwSs9jdpVG100LWR .edgeLabel rect{opacity:0.9}#mermaid-svg-FwSs9jdpVG100LWR .edgeLabel span{color:#333}#mermaid-svg-FwSs9jdpVG100LWR .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-FwSs9jdpVG100LWR .cluster text{fill:#333}#mermaid-svg-FwSs9jdpVG100LWR div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-FwSs9jdpVG100LWR .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-FwSs9jdpVG100LWR text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-FwSs9jdpVG100LWR .actor-line{stroke:grey}#mermaid-svg-FwSs9jdpVG100LWR .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-FwSs9jdpVG100LWR .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-FwSs9jdpVG100LWR #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-FwSs9jdpVG100LWR .sequenceNumber{fill:#fff}#mermaid-svg-FwSs9jdpVG100LWR #sequencenumber{fill:#333}#mermaid-svg-FwSs9jdpVG100LWR #crosshead path{fill:#333;stroke:#333}#mermaid-svg-FwSs9jdpVG100LWR .messageText{fill:#333;stroke:#333}#mermaid-svg-FwSs9jdpVG100LWR .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-FwSs9jdpVG100LWR .labelText,#mermaid-svg-FwSs9jdpVG100LWR .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-FwSs9jdpVG100LWR .loopText,#mermaid-svg-FwSs9jdpVG100LWR .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-FwSs9jdpVG100LWR .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-FwSs9jdpVG100LWR .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-FwSs9jdpVG100LWR .noteText,#mermaid-svg-FwSs9jdpVG100LWR .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-FwSs9jdpVG100LWR .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-FwSs9jdpVG100LWR .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-FwSs9jdpVG100LWR .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-FwSs9jdpVG100LWR .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-FwSs9jdpVG100LWR .section{stroke:none;opacity:0.2}#mermaid-svg-FwSs9jdpVG100LWR .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-FwSs9jdpVG100LWR .section2{fill:#fff400}#mermaid-svg-FwSs9jdpVG100LWR .section1,#mermaid-svg-FwSs9jdpVG100LWR .section3{fill:#fff;opacity:0.2}#mermaid-svg-FwSs9jdpVG100LWR .sectionTitle0{fill:#333}#mermaid-svg-FwSs9jdpVG100LWR .sectionTitle1{fill:#333}#mermaid-svg-FwSs9jdpVG100LWR .sectionTitle2{fill:#333}#mermaid-svg-FwSs9jdpVG100LWR .sectionTitle3{fill:#333}#mermaid-svg-FwSs9jdpVG100LWR .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-FwSs9jdpVG100LWR .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-FwSs9jdpVG100LWR .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-FwSs9jdpVG100LWR .grid path{stroke-width:0}#mermaid-svg-FwSs9jdpVG100LWR .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-FwSs9jdpVG100LWR .task{stroke-width:2}#mermaid-svg-FwSs9jdpVG100LWR .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-FwSs9jdpVG100LWR .taskText:not([font-size]){font-size:11px}#mermaid-svg-FwSs9jdpVG100LWR .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-FwSs9jdpVG100LWR .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-FwSs9jdpVG100LWR .task.clickable{cursor:pointer}#mermaid-svg-FwSs9jdpVG100LWR .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-FwSs9jdpVG100LWR .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-FwSs9jdpVG100LWR .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-FwSs9jdpVG100LWR .taskText0,#mermaid-svg-FwSs9jdpVG100LWR .taskText1,#mermaid-svg-FwSs9jdpVG100LWR .taskText2,#mermaid-svg-FwSs9jdpVG100LWR .taskText3{fill:#fff}#mermaid-svg-FwSs9jdpVG100LWR .task0,#mermaid-svg-FwSs9jdpVG100LWR .task1,#mermaid-svg-FwSs9jdpVG100LWR .task2,#mermaid-svg-FwSs9jdpVG100LWR .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-FwSs9jdpVG100LWR .taskTextOutside0,#mermaid-svg-FwSs9jdpVG100LWR .taskTextOutside2{fill:#000}#mermaid-svg-FwSs9jdpVG100LWR .taskTextOutside1,#mermaid-svg-FwSs9jdpVG100LWR .taskTextOutside3{fill:#000}#mermaid-svg-FwSs9jdpVG100LWR .active0,#mermaid-svg-FwSs9jdpVG100LWR .active1,#mermaid-svg-FwSs9jdpVG100LWR .active2,#mermaid-svg-FwSs9jdpVG100LWR .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-FwSs9jdpVG100LWR .activeText0,#mermaid-svg-FwSs9jdpVG100LWR .activeText1,#mermaid-svg-FwSs9jdpVG100LWR .activeText2,#mermaid-svg-FwSs9jdpVG100LWR .activeText3{fill:#000 !important}#mermaid-svg-FwSs9jdpVG100LWR .done0,#mermaid-svg-FwSs9jdpVG100LWR .done1,#mermaid-svg-FwSs9jdpVG100LWR .done2,#mermaid-svg-FwSs9jdpVG100LWR .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-FwSs9jdpVG100LWR .doneText0,#mermaid-svg-FwSs9jdpVG100LWR .doneText1,#mermaid-svg-FwSs9jdpVG100LWR .doneText2,#mermaid-svg-FwSs9jdpVG100LWR .doneText3{fill:#000 !important}#mermaid-svg-FwSs9jdpVG100LWR .crit0,#mermaid-svg-FwSs9jdpVG100LWR .crit1,#mermaid-svg-FwSs9jdpVG100LWR .crit2,#mermaid-svg-FwSs9jdpVG100LWR .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-FwSs9jdpVG100LWR .activeCrit0,#mermaid-svg-FwSs9jdpVG100LWR .activeCrit1,#mermaid-svg-FwSs9jdpVG100LWR .activeCrit2,#mermaid-svg-FwSs9jdpVG100LWR .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-FwSs9jdpVG100LWR .doneCrit0,#mermaid-svg-FwSs9jdpVG100LWR .doneCrit1,#mermaid-svg-FwSs9jdpVG100LWR .doneCrit2,#mermaid-svg-FwSs9jdpVG100LWR .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-FwSs9jdpVG100LWR .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-FwSs9jdpVG100LWR .milestoneText{font-style:italic}#mermaid-svg-FwSs9jdpVG100LWR .doneCritText0,#mermaid-svg-FwSs9jdpVG100LWR .doneCritText1,#mermaid-svg-FwSs9jdpVG100LWR .doneCritText2,#mermaid-svg-FwSs9jdpVG100LWR .doneCritText3{fill:#000 !important}#mermaid-svg-FwSs9jdpVG100LWR .activeCritText0,#mermaid-svg-FwSs9jdpVG100LWR .activeCritText1,#mermaid-svg-FwSs9jdpVG100LWR .activeCritText2,#mermaid-svg-FwSs9jdpVG100LWR .activeCritText3{fill:#000 !important}#mermaid-svg-FwSs9jdpVG100LWR .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-FwSs9jdpVG100LWR g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-FwSs9jdpVG100LWR g.classGroup text .title{font-weight:bolder}#mermaid-svg-FwSs9jdpVG100LWR g.clickable{cursor:pointer}#mermaid-svg-FwSs9jdpVG100LWR g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-FwSs9jdpVG100LWR g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-FwSs9jdpVG100LWR .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-FwSs9jdpVG100LWR .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-FwSs9jdpVG100LWR .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-FwSs9jdpVG100LWR .dashed-line{stroke-dasharray:3}#mermaid-svg-FwSs9jdpVG100LWR #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-FwSs9jdpVG100LWR #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-FwSs9jdpVG100LWR #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-FwSs9jdpVG100LWR #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-FwSs9jdpVG100LWR #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-FwSs9jdpVG100LWR #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-FwSs9jdpVG100LWR #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-FwSs9jdpVG100LWR #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-FwSs9jdpVG100LWR .commit-id,#mermaid-svg-FwSs9jdpVG100LWR .commit-msg,#mermaid-svg-FwSs9jdpVG100LWR .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-FwSs9jdpVG100LWR .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-FwSs9jdpVG100LWR .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-FwSs9jdpVG100LWR g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-FwSs9jdpVG100LWR g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-FwSs9jdpVG100LWR g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-FwSs9jdpVG100LWR g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-FwSs9jdpVG100LWR g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-FwSs9jdpVG100LWR g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-FwSs9jdpVG100LWR .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-FwSs9jdpVG100LWR .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-FwSs9jdpVG100LWR .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-FwSs9jdpVG100LWR .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-FwSs9jdpVG100LWR .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-FwSs9jdpVG100LWR .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-FwSs9jdpVG100LWR .edgeLabel text{fill:#333}#mermaid-svg-FwSs9jdpVG100LWR .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-FwSs9jdpVG100LWR .node circle.state-start{fill:black;stroke:black}#mermaid-svg-FwSs9jdpVG100LWR .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-FwSs9jdpVG100LWR #statediagram-barbEnd{fill:#9370db}#mermaid-svg-FwSs9jdpVG100LWR .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-FwSs9jdpVG100LWR .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-FwSs9jdpVG100LWR .statediagram-state .divider{stroke:#9370db}#mermaid-svg-FwSs9jdpVG100LWR .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-FwSs9jdpVG100LWR .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-FwSs9jdpVG100LWR .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-FwSs9jdpVG100LWR .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-FwSs9jdpVG100LWR .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-FwSs9jdpVG100LWR .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-FwSs9jdpVG100LWR .note-edge{stroke-dasharray:5}#mermaid-svg-FwSs9jdpVG100LWR .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-FwSs9jdpVG100LWR .error-icon{fill:#522}#mermaid-svg-FwSs9jdpVG100LWR .error-text{fill:#522;stroke:#522}#mermaid-svg-FwSs9jdpVG100LWR .edge-thickness-normal{stroke-width:2px}#mermaid-svg-FwSs9jdpVG100LWR .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-FwSs9jdpVG100LWR .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-FwSs9jdpVG100LWR .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-FwSs9jdpVG100LWR .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-FwSs9jdpVG100LWR .marker{fill:#333}#mermaid-svg-FwSs9jdpVG100LWR .marker.cross{stroke:#333} :root { --mermaid-font-family: "trebuchet ms", verdana, arial;} #mermaid-svg-FwSs9jdpVG100LWR { color: rgba(0, 0, 0, 0.75); font: ; } 输入数据 A=H0 B=H1 C=H2 D=H4 E=H5 t=0 E=D D=C C=B<<30 B=A A=((A<<5)+ft(B,C,D)+E+Wt+Kt) t++ t<=79 H0=H0+A H1=H1+B H2=H2+C H2=H3+D H4=H4+E 输出结果

    1).将A、B、C、D、E、t初始化,A=H0、B=H1、C=H2、D=H3、E=H4,t = 0,其中Hn为传入的值;     2).E = D;     3).D = C;     4).C = B<<30;     5).B = A;     6).A = A<<5+ft(B,C,D)+E+Wt+Kt.     其中ft为函数运算其定义如下:         ft(B,C,D) = (B&C)|((~B)&D) ( 0 <= t <= 19);         ft(B,C,D) = BCD (20 <= t <= 39);         ft(B,C,D) = (B&C)|(B&D) OR (C&D) (40 <= t <= 59);         ft(B,C,D) = BCD (60 <= t <= 79);     其中Wt为格式化数据Xn的一个元素。     其中Kt为常量,定义如下:         Kt = 0x5A827999 (0 <= t <= 19)         Kt = 0x6ED9EBA1 (20 <= t <= 39)         Kt = 0x8F1BBCDC (40 <= t <= 59)         Kt = 0xCA62C1D6 (60 <= t <= 79)     7).t++;     8).循环步骤2到6直至t>79;     9).与初始值求和H0=H0+A、H1=H1+B、H2=H2+C、H3=H3+D、H4=H4+E;     10).输出单次计算结果H0、H1、H2、H3、H4;

7.格式化输出

    计算完成后以字节形式输出摘要信息。

最新回复(0)