var int a0 := 0x67452301 //A
var int b0 := 0xefcdab89 //B
var int c0 := 0x98badcfe //C
var int d0 := 0x10325476 //D
for each 512-bit chunk of message
break chunk into sixteen 32-bit words M[j], 0 ≤ j ≤ 15
//Initialize hash value for this chunk:
var int A := a0
var int B := b0
var int C := c0
var int D := d0
//Main loop:
for i from 0 to 63
if 0 ≤ i ≤ 15 then
F := (B and C) or ((not B) and D)
g := i
else if 16 ≤ i ≤ 31
F := (D and B) or ((not D) and C)
g := (5×i + 1) mod 16
else if 32 ≤ i ≤ 47
F := B xor C xor D
g := (3×i + 5) mod 16
else if 48 ≤ i ≤ 63
F := C xor (B or (not D))
g := (7×i) mod 16
dTemp := D
D := C
C := B
B := B + leftrotate((A + F + K[i] + M[g]), s[i])
A := dTemp
end for
//Add this chunk's hash to result so far:
a0 := a0 + A
b0 := b0 + B
c0 := c0 + C
d0 := d0 + D
end for
這是取自維基百科,特別是從here,以查看完整的代碼。這個函數如何比較hexnumbers?
我不明白什麼,例如(B and C)
生產,因爲B
和C
是hexes。 (Big endian)
我在這裏沒有看到與安全相關的問題。如果它與安全性有關,也許你可以重新說明你所擁有的問題。 –
這些hexnumbers只是常規數字,用十六進制表示法爲程序員的眼睛寫的。引擎蓋下全是1和0。 and,or,not和xor是[按位操作](https://en.wikipedia.org/wiki/Bitwise_operation#Bitwise_operators)。 – icio