Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Private Function

final

Private Function
std.crypto.siphash.SipHashStateless.final
fn final(self: *Self, b: []const u8) T

Params

  • self: *Self
  • b: []const u8

File

crypto/siphash.zig:89
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
        fn final(self: *Self, b: []const u8) T {
            std.debug.assert(b.len < 8);

            self.msg_len +%= @as(u8, @truncate(b.len));

            var buf: [8]u8 = @splat(0);
            @memcpy(buf[0..b.len], b);
            buf[7] = self.msg_len;
            self.round(buf);

            if (T == u128) {
                self.v2 ^= 0xee;
            } else {
                self.v2 ^= 0xff;
            }

            comptime var i: usize = 0;
            inline while (i < d_rounds) : (i += 1) {
                @call(.always_inline, sipRound, .{self});
            }

            const b1 = self.v0 ^ self.v1 ^ self.v2 ^ self.v3;
            if (T == u64) {
                return b1;
            }

            self.v1 ^= 0xdd;

            comptime var j: usize = 0;
            inline while (j < d_rounds) : (j += 1) {
                @call(.always_inline, sipRound, .{self});
            }

            const b2 = self.v0 ^ self.v1 ^ self.v2 ^ self.v3;
            return (@as(u128, b2) << 64) | b1;
        }