SHA-256: Difference between revisions

m
Minor code improvement
m (Reformatting text.)
m (Minor code improvement)
Line 2,204:
words[j / 4] |= ( bytes[i * BLOCK_LENGTH + j] & 0xff ) << ( ( 3 - j % 4 ) * 8 );
}
for ( int j = 16; j < 64BLOCK_LENGTH; j++ ) {
words[j] = sigma(3, words[j - 2]) + words[j - 7] + sigma(2, words[j - 15]) + words[j - 16];
}
int a = hash[0], b = hash[1], c = hash[2], d = hash[3],
e = hash[4], f = hash[5], g = hash[6], h = hash[7];
for ( int j = 0; j < 64BLOCK_LENGTH; j++ ) {
int t = h + sigma(1, e) + ch(e, f, g) + kk[j] + words[j];
int tt = sigma(0, a) + maj(a, b, c);
Line 2,225:
StringBuilder result = new StringBuilder();
for ( int i = 0; i < 64BLOCK_LENGTH; i++ ) {
result.append(String.format("%1x", ( hash[i / 8] >>> ( 7 - i % 8 ) * 4 ) & 0xf ));
}
894

edits