Skip to content

Commit

Permalink
simplify padding of last chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
mherkender committed Apr 2, 2012
1 parent 5ab9f68 commit fcc48da
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sha1.as
Expand Up @@ -12,9 +12,9 @@ package {

// sha-1 adds a 64-bit integer that has the size
// BUT enough zeros need to be added so that they'll be at the end of a chunk
const newLen:uint = Math.ceil((originalLength + 9) / 64) * 64 - originalLength - 9;
if (newLen) {
byteInput.writeBytes(zeroByteArray, 0, newLen);
const padding:uint = (55 - originalLength) & 0x3f;
if (padding != 0) {
byteInput.writeBytes(zeroByteArray, 0, padding);
}

// append the original size of the input
Expand Down

0 comments on commit fcc48da

Please sign in to comment.