admins.html: include current irc contact information
[girocco.git] / src / ltsha1-test.sh
blob1aab5e65e79f15c22966653e330f581e1dca6996
1 #!/bin/sh
3 # License: public domain -or- http://www.wtfpl.net/txt/copying/
5 die() { >&2 printf 'Bail out! %s\n' "$*"; exit 1; }
7 testnum=0
9 # $1 => value to hash (may contain escapes)
10 # $2 => lowercase sha256 hash expected
11 # $3... => test name
12 test_sha1() {
13 _val="$1"; shift
14 _hash="$1"; shift
15 _test="$*"
16 _check="$(printf '%b' "$_val" | ./ltsha1)" ||
17 die "could not run ltsha1 utility"
18 _result="ok"
19 [ "$_check" = "$_hash" ] || _result="not ok"
20 testnum="$(( $testnum + 1 ))"
21 printf '%s %u - %s\n' "$_result" "$testnum" "$_test"
24 echo '1..4'
26 test_sha1 \
27 "abc" \
28 a9993e364706816aba3e25717850c26c9cd0d89d \
29 abc
31 test_sha1 \
32 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" \
33 84983e441c3bd26ebaae4aa1f95129e5e54670f1 \
34 abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
36 test_sha1 \
37 "123456789" \
38 f7c3bc1d808e04732adf679965ccc34ca7ae3441 \
39 123456789
41 test_sha1 \
42 "The quick brown fox jumped over the lazy dog.\n" \
43 bae5ed658ab3546aee12f23f36392f35dba1ebdd \
44 "quick brown fox"
46 exit 0