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