import streams, strutils
let f = newFileStream("blake2b-kat.txt", fmRead)
if not isNil(f):
defer: close(f)
var input, key, hash: string
var readLine: TaintedString = newString(1024)
var line: string
var idx: int = 0
while f.readLine(readLine):
line = readLine.strip()
if len(line) < 1:
idx = 0
else:
case idx
of 0:
if line[0..2] == "in:":
input = line[4..^0]
inc(idx)
else:
echo "First line did not start with 'in:'!"
idx = 0
of 1:
if line[0..3] == "key:":
key = line[5..^0]
inc(idx)
else:
echo "Second line did not start with 'key:'!"
idx = 0
of 2:
if line[0..4] == "hash:":
hash = line[5..^0]
echo "Input: ", input, "; Key: ", key, "; Hash: ", hash, "\n"
idx = 0
else:
echo "Third line did not start with 'hash:'!"
idx = 0
else:
echo "Hit invalid index"
idx = 0