blob: 9a707c350570ee1dbfa57ea1c9ab1d790052d31f (
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
|
use "core"
action [file with hash %hash]
lua> ".."
local Hash = require("openssl.digest")
for filename in io.popen('find -L . -type f -name "*.nom"'):lines() do
local file = io.open(filename)
local contents = file:read("*a")
file:close()
local hash = Hash.new("sha1"):final(contents)
local hex = hash:gsub('.', function(c) return string.format('%02x', string.byte(c)) end)
if hex == \%hash then
return filename
end
end
action [hash %, sha1 %]
%hashlib <- (=lua "require('openssl.digest')")
%hash <- (=lua "\%hashlib.new('sha1'):final(\%)")
return: =lua "\%hash:gsub('.', function(c) return string.format('%02x', string.byte(c)) end)"
parse [hash of file %filename] as
sha1: =lua "io.open(\%filename):read('*a')"
|