]> Sergey Matveev's repositories - meta4ra.git/blob - bin/meta4ra-hashes-detect
20d48150f13f840e8085f3c1b1c0535d88766f93
[meta4ra.git] / bin / meta4ra-hashes-detect
1 #!/bin/sh -e
2
3 hw="hello world"
4 hashes=""
5
6 desired="$1"
7
8 check() {
9     local name="$1"
10     if [ -n "$desired" ] && [ $desired != "$name" ] ; then return 1 ; fi
11     local cmd="$2"
12     local hsh="$3"
13     our=$(echo -n hello world | sh -e -c "$cmd" | { read h rem ; printf %s "$h"; })
14     [ $hsh = "$our" ] && hashes="$hashes,$name:$cmd"
15 }
16
17 hsh=d74981efa70a0c880b8d8c1985d075dbcbf679b99a5f9914e5aaf96b831a9e24
18 check blake3-256 b3sum $hsh || :
19
20 hsh=021ced8799296ceca557832ab941a50b4a11f83478cf141f51f933f653ab9fbcc05a037cddbed06e309bf334942c4e58cdf1a46e237911ccd7fcf9787cbc7fd0
21 check blake2b-512 b2sum $hsh ||
22 check blake2b-512 "openssl blake2b512 -r" $hsh || :
23
24 hsh=256c83b297114d201b30179f3f0ef0cace9783622da5974326b436178aeef610
25 check blake2b-256 "b2sum -l 256" $hsh || :
26
27 hsh=8b4830244fc36daa11177311dc6bf7636376180dce2d29193335878142e7d6f5e9016beba729e0a353dd2fd421c8b2022ee8927f0bce6b88631bb01be2e0f5ba
28 check skein-512 skein512 $hsh || :
29
30 hsh=3a9159f071e4dd1c8c4f968607c30942e120d8156b8b1e72e0d376e8871cb8b8
31 check shake128 goshake128 $hsh || # go.stargrave.org/gosha3
32 check shake128 "sha3sum -a 128000 | dd bs=1 count=64 2> /dev/null" $hsh || : # p5-Digest-SHA3
33 # openssl shake128 -- useless, as it outputs only 128 bits
34
35 hsh=369771bb2cb9d2b04c1d54cca487e372d9f187f73f7ba3f65b95c8ee7798c527f4f3c2d55c2d46a29f2e945d469c3df27853a8735271f5cc2d9e889544357116
36 check shake256 goshake256 $hsh ||
37 check shake256 "sha3sum -a 256000 | dd bs=1 count=128 2> /dev/null" $hsh || :
38
39 hsh=309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f
40 check sha-512 sha512 $hsh ||
41 check sha-512 sha512sum $hsh ||
42 check sha-512 "libressl dgst -sha512" $hsh ||
43 check sha-512 "openssl sha512 -r" $hsh || :
44
45 hsh=b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
46 check sha-256 sha256 $hsh ||
47 check sha-256 sha256sum $hsh ||
48 check sha-256 "libressl dgst -sha256" $hsh ||
49 check sha-256 "openssl sha256 -r" $hsh || :
50
51 hsh=84d883ede9fa6ce855d82d8c278ecd9f5fc88bf0602831ae0c38b9b506ea3cb02f3fa076b8f5664adf1ff862c0157da4cc9a83e141b738ff9268a9ba3ed6f563
52 check streebog-512 "nettle-hash --algorithm=streebog512 --raw | xxd -c 0 -p" $hsh ||
53 check streebog-512 "nettle-hash --algorithm=streebog512 --raw | hexdump -v -e '/1 \"%02x\"' ; echo" $hsh ||
54 check streebog-512 "libressl dgst -streebog512" $hsh ||
55 check streebog-512 streebog512 $hsh || : # go.cypherpunks.ru/gogost
56
57 hsh=c600fd9dd049cf8abd2f5b32e840d2cb0e41ea44de1c155dcd88dc84fe58a855
58 check streebog-256 "nettle-hash --algorithm=streebog256 --raw | xxd -c 0 -p" $hsh ||
59 check streebog-256 "nettle-hash --algorithm=streebog256 --raw | hexdump -v -e '/1 \"%02x\"' ; echo" $hsh ||
60 check streebog-256 "libressl dgst -streebog256" $hsh ||
61 check streebog-256 streebog256 $hsh || :
62
63 hsh=df8d09e93f874900a99b8775cc15b6c7
64 check xxh3-128 "xxhsum -H128" $hsh || :
65
66 [ -n "$hashes" ]
67 echo ${hashes#,}