blob: cec264f338e178f04fc08289f71e3f985d62d6df (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
const std = @import("std");
pub fn main() !void {
const stdin = std.io.getStdIn().reader().any();
const stdout = std.io.getStdOut().writer().any();
const key = try stdin.readBytesNoEof(16);
const aes = std.crypto.core.aes.Aes128.initEnc(key);
var input: [1024 * 16]u8 = undefined;
while (true) {
const unalignedLen = try stdin.read(&input);
if (unalignedLen == 0) break;
const len = std.mem.alignBackward(usize, unalignedLen, 16);
std.debug.assert(len == unalignedLen);
var i: usize = 0;
while (i < len) : (i += 16) {
aes.encrypt(input[i..][0..16], input[i..][0..16]);
}
try stdout.writeAll(input[0..len]);
}
}
|