definition f::"[nat, word32, word32, word32] => word32" where
"f j x y z =
(if ( 0 <=
else if (16 <= j & j <= 31) then (x AND y) OR (NOT x AND z)
else if (32 <= j & j <= 47) then (x OR NOT y) XOR z
else if (48 <= j & j <= 63) then (x AND z) OR (y AND NOT z)
else if (64 <= j & j <= 79) then x XOR (y OR NOT z)
else 0)"
\<comment> ‹added constants (hexadecimal)›
definition K::"nat => word32" where
"K j =
(if ( 0 <= j & j <= 15) then0x00000000
else if (16 <= j & j <= 31) then0x5A827999
else if (32 <= j & j <= 47) then0x6ED9EBA1
else if (48 <= j & j <= 63) then 0x8F1BBCDC elseif (64 <= j & j <= 79) then 0xA953FD4E else0)"
definition K'::"nat => word32"
where "K' j =
(if ( 0 <= j & j <= 15) then 0x50A28BE6 elseif (16 <= j & j <= 31) then 0x5C4DD124 elseif (32 <= j & j <= 47) then 0x6D703EF3 elseif (48 <= j & j <= 63) then 0x7A6D76E9 elseif (64 <= j & j <= 79) then 0x00000000 else0)"
\<comment> \<open>selection of message word\<close>
\<comment> \<open>Initial value (hexadecimal)\<close>
definition h0_0::word32 where "h0_0 = 0x67452301"
definition h1_0::word32 where "h1_0 = 0xEFCDAB89"
definition h2_0::word32 where "h2_0 = 0x98BADCFE"
definition h3_0::word32 where "h3_0 = 0x10325476"
definition h4_0::word32 where "h4_0 = 0xC3D2E1F0"
definition h_0::chain where "h_0 = (h0_0, h1_0, h2_0, h3_0, h4_0)"
definition step_l :: "[ block,
chain,
nat
] => chain"
where "step_l X c j =
(let (A, B, C, D, E) = c in
(\<comment> \<open>\<open>A:\<close>\<close> E,
\<comment> \<open>\<open>B:\<close>\<close> word_rotl (s j) (A + f j B C D + X (r j) + K j) + E,
\<comment> \<open>\<open>C:\<close>\<close> B,
\<comment> \<open>\<open>D:\<close>\<close> word_rotl 10 C,
\<comment> \<open>\<open>E:\<close>\<close> D))"
definition step_r :: "[ block,
chain,
nat
] \<Rightarrow> chain"
where "step_r X c' j =
(let (A', B', C', D', E') = c' in
(\<comment> \<open>\<open>A':\<close>\<close> E',
\<comment> \<open>\<open>B':\<close>\<close> word_rotl (s' j) (A' + f (79 - j) B' C' D' + X (r' j) + K' j) + E',
\<comment> \<open>\<open>C':\<close>\<close> B',
\<comment> \<open>\<open>D':\<close>\<close> word_rotl 10 C',
\<comment> \<open>\<open>E':\<close>\<close> D'))"
definition step_both :: "[ block, chain * chain, nat ] \<Rightarrow> chain * chain"
where "step_both X cc j = (case cc of (c, c') \<Rightarrow>
(step_l X c j, step_r X c' j))"
definition steps::"[ block, chain * chain, nat] \<Rightarrow> chain * chain"
where "steps X cc i = foldl (step_both X) cc [0..<i]"
definition round::"[ block, chain ] \<Rightarrow> chain"
where "round X h =
(let (h0, h1, h2, h3, h4) = h in
let ((A, B, C, D, E), (A', B', C', D', E')) = steps X (h, h) 80 in
(\<comment> \<open>\<open>h0:\<close>\<close> h1 + C + D',
\<comment> \<open>\<open>h1:\<close>\<close> h2 + D + E',
\<comment> \<open>\<open>h2:\<close>\<close> h3 + E + A',
\<comment> \<open>\<open>h3:\<close>\<close> h4 + A + B',
\<comment> \<open>\<open>h4:\<close>\<close> h0 + B + C'))"
definition rmd_body::"[ message, chain, nat ] => chain"
where "rmd_body X h i = round (X i) h"
definition rounds::"message \<Rightarrow> chain \<Rightarrow> nat \<Rightarrow> chain"
where "rounds X h i = foldl (rmd_body X) h_0 [0..<i]"
definition rmd :: "message \<Rightarrow> nat \<Rightarrow> chain"
where "rmd X len = rounds X h_0 len"
end
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.8 Sekunden
(vorverarbeitet am 2026-10-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.