diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.zig | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main.zig b/src/main.zig index a93c0ea..b24faea 100644 --- a/src/main.zig +++ b/src/main.zig | |||
@@ -286,11 +286,11 @@ fn encode( | |||
286 | var buf: [prefix_len + data_len + 2]u8 = undefined; | 286 | var buf: [prefix_len + data_len + 2]u8 = undefined; |
287 | defer wipeBytes(&buf); | 287 | defer wipeBytes(&buf); |
288 | 288 | ||
289 | mem.copy(u8, &buf, prefix[0..]); | 289 | mem.copyForwards(u8, &buf, prefix[0..]); |
290 | mem.copy(u8, buf[prefix_len..], data[0..]); | 290 | mem.copyForwards(u8, buf[prefix_len..], data[0..]); |
291 | const off = prefix_len + data_len; | 291 | const off = prefix_len + data_len; |
292 | const checksum = crc16.make(buf[0..off]); | 292 | const checksum = crc16.make(buf[0..off]); |
293 | mem.writeIntLittle(u16, buf[buf.len - 2 .. buf.len], checksum); | 293 | mem.writeInt(u16, buf[buf.len - 2 .. buf.len], checksum, .little); |
294 | 294 | ||
295 | var text: encoded_key(prefix_len, data_len) = undefined; | 295 | var text: encoded_key(prefix_len, data_len) = undefined; |
296 | std.debug.assert(base32.Encoder.encode(&text, &buf).len == text.len); | 296 | std.debug.assert(base32.Encoder.encode(&text, &buf).len == text.len); |
@@ -321,7 +321,7 @@ fn decode( | |||
321 | defer wipeBytes(&raw); | 321 | defer wipeBytes(&raw); |
322 | std.debug.assert((try base32.Decoder.decode(&raw, text[0..])).len == raw.len); | 322 | std.debug.assert((try base32.Decoder.decode(&raw, text[0..])).len == raw.len); |
323 | 323 | ||
324 | const checksum = mem.readIntLittle(u16, raw[raw.len - 2 .. raw.len]); | 324 | const checksum = mem.readInt(u16, raw[raw.len - 2 .. raw.len], .little); |
325 | try crc16.validate(raw[0 .. raw.len - 2], checksum); | 325 | try crc16.validate(raw[0 .. raw.len - 2], checksum); |
326 | 326 | ||
327 | return DecodedNkey(prefix_len, data_len){ | 327 | return DecodedNkey(prefix_len, data_len){ |
@@ -347,7 +347,7 @@ pub fn isValidEncoding(text: []const u8) bool { | |||
347 | } | 347 | } |
348 | std.debug.assert(wrote_n_total == expect_len); | 348 | std.debug.assert(wrote_n_total == expect_len); |
349 | if (crc_buf_len != 2) unreachable; | 349 | if (crc_buf_len != 2) unreachable; |
350 | const got_crc = mem.readIntLittle(u16, &crc_buf); | 350 | const got_crc = mem.readInt(u16, &crc_buf, .little); |
351 | return made_crc == got_crc; | 351 | return made_crc == got_crc; |
352 | } | 352 | } |
353 | 353 | ||