cleanup: replace C for loops with range

This commit is contained in:
spaceface777 2020-02-24 17:55:16 +01:00 committed by GitHub
parent 5918946feb
commit ef8c1203b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 168 additions and 170 deletions

View file

@ -105,7 +105,7 @@ fn block_generic(dig mut Digest, p_ []byte) {
mut h6 := dig.h[6]
mut h7 := dig.h[7]
for p.len >= Chunk {
for i := 0; i < 16; i++ {
for i in 0..16 {
j := i * 8
w[i] = (u64(p[j])<<56) | (u64(p[j + 1])<<48) | (u64(p[j + 2])<<40) | (u64(p[j + 3])<<32) | (u64(p[j + 4])<<24) | (u64(p[j + 5])<<16) | (u64(p[j + 6])<<8) | u64(p[j + 7])
}
@ -124,7 +124,7 @@ fn block_generic(dig mut Digest, p_ []byte) {
mut f := h5
mut g := h6
mut h := h7
for i := 0; i < 80; i++ {
for i in 0..80 {
t1 := h + (bits.rotate_left_64(e, -14) ^ bits.rotate_left_64(e, -18) ^ bits.rotate_left_64(e, -41)) + ((e & f) ^ (~e & g)) + _k[i] + w[i]
t2 := (bits.rotate_left_64(a, -28) ^ bits.rotate_left_64(a, -34) ^ bits.rotate_left_64(a, -39)) + ((a & b) ^ (a & c) ^ (b & c))
h = g