DoxigAlpha

update

Function parameters

Parameters

#
d:*Sha1
b:[]const u8

Type definitions in this namespace

Types

#

Functions in this namespace

Functions

#

= 64

Values

#

Source

Implementation

#
pub fn update(d: *Sha1, b: []const u8) void {
    var off: usize = 0;

    // Partial buffer exists from previous update. Copy into buffer then hash.
    if (d.buf_len != 0 and d.buf_len + b.len >= 64) {
        off += 64 - d.buf_len;
        @memcpy(d.buf[d.buf_len..][0..off], b[0..off]);

        d.round(d.buf[0..]);
        d.buf_len = 0;
    }

    // Full middle blocks.
    while (off + 64 <= b.len) : (off += 64) {
        d.round(b[off..][0..64]);
    }

    // Copy any remainder for next pass.
    @memcpy(d.buf[d.buf_len..][0 .. b.len - off], b[off..]);
    d.buf_len += @as(u8, @intCast(b[off..].len));

    d.total_len += b.len;
}