summaryrefslogtreecommitdiff
path: root/disk-simple-mask.lua
blob: ba41f7bece0ea931b8110d2d80ab70f980e5dca2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env lua
local disk = require "disk"
local eyes = require "eyes"
local format = require "format"
local reading = require "reading"


local function mask (ring, index, value)
	local offset = (index - 1) % #ring
	if ring[offset + 1] == 0 then
		return value
	else
		return 0
	end
end


for _, message in ipairs(eyes) do
	local values = {}
	for index, a, b, c in reading.trigrams(message) do
		a = mask(disk.eyes1, index, a)
		b = mask(disk.eyes2, index, b)
		c = mask(disk.eyes3, index, c)
		table.insert(values, reading.trigram_to_value(a, b, c))
	end
	print(format.ascii32(values))
end