blob: 188df78f282e9728ad0edda6ab74a9f23d9a9299 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/usr/bin/env nomsu -V3.6.5.6
#
This file defines some actions for hashing files and looking up files by hash.
use "lib/os.nom"
use "lib/base64.nom"
%hashlib = (=lua "require('openssl.digest')")
test:
assume ((hash "hello world") == "Kq5sNclPz7QV2+lfQIuc6R7oRu0=")
action [hash %, sha1 %]:
%hash = (=lua "\%hashlib.new('sha1'):final(\%)")
return (base64 %hash)
action [file with hash %hash]:
for file %filename in ".":
%contents = (read file %filename)
%file_hash = (hash %contents)
if (%file_hash == %hash): return %filename
parse [hash of file %filename] as (sha1 (read file %filename))
|