NAME=rz-hash -a entropy
FILE=-
CMDS=!rz-hash -a entropy bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: 0x00000000-0x00001a35 entropy: 3.27819072
EOF
RUN

NAME=rz-hash -a md5
FILE=-
CMDS=!rz-hash -a md5 bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: 0x00000000-0x00001a35 md5: c957bd5bd6204470256bc15248ccafd4
EOF
RUN

NAME=rz-hash -a sha1
FILE=-
CMDS=!rz-hash -a sha1 bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: 0x00000000-0x00001a35 sha1: 687c82d13cb27f0600d8e57edc784282c1732f56
EOF
RUN

NAME=rz-hash -a sha256
FILE=-
CMDS=!rz-hash -a sha256 bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: 0x00000000-0x00001a35 sha256: 7bdbf25324af1946ec0b16dbf928875a588a786f7c279cd115729c5a3a297a55
EOF
RUN

NAME=rz-hash -a sha384
FILE=-
CMDS=!rz-hash -a sha384 bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: 0x00000000-0x00001a35 sha384: a6fed224b0b5892ab44839b5ae6a12e54fb3393b5f1e1ca174fb5a0032c994f1c492c5b3a090518d8a60875223977ba4
EOF
RUN

NAME=rz-hash -a sha512
FILE=-
CMDS=!rz-hash -a sha512 bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: 0x00000000-0x00001a35 sha512: 2640b1ff96870fb78a3d8ae6b51595ca86c37e25443b2e8c5441e77d11cdb3830ece8d791561c22788d37d7f22c99cdabf8f798826c0ff441901e6157890fee6
EOF
RUN

NAME=rz-hash -h
FILE=-
CMDS=!rz-hash~Usage
EXPECT=<<EOF
Usage: rz-hash [-BhjkLqrv] [-b S] [-a A] [-c H] [-E A] [-s S] [-f O] [-t O] [file] ...
EOF
RUN

NAME=rz-hash -a md5 -s "admin"
FILE=-
CMDS=!rz-hash -a md5 -s "admin"
EXPECT=<<EOF
0x00000000-0x00000004 md5: 21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rz-hash -a md5 -e -s "admin"
FILE=-
CMDS=!rz-hash -a md5 -e -s "admin"
EXPECT=<<EOF
0x00000000-0x00000004 md5: c31f804a0e4a8943a7a5577a292f2321
EOF
RUN

NAME=rz-hash -a sha1,sha256 -s "admin"
FILE=-
CMDS=!rz-hash -a sha1,sha256 -s "admin"
EXPECT=<<EOF
0x00000000-0x00000004 sha1: d033e22ae348aeb5660fc2140aec35850c4da997
0x00000000-0x00000004 sha256: 8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
EOF
RUN

NAME=rz-hash -D base64 -s "YWRtaW4="
FILE=-
CMDS=!rz-hash -D base64 -s "YWRtaW4="
EXPECT=admin
RUN

NAME=rz-hash -E base64 -s "admin"
FILE=-
CMDS=!rz-hash -E base64 -s "admin"
EXPECT=YWRtaW4=
RUN

NAME=rz-hash -E base64 -x "61646d696e"
FILE=-
CMDS=!rz-hash -E base64 -x "61646d696e"
EXPECT=YWRtaW4=
RUN

NAME=rz-hash -a md5 -x "61646d696e"
FILE=-
CMDS=!rz-hash -a md5 -x "61646d696e"
EXPECT=<<EOF
0x00000000-0x00000004 md5: 21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rz-hash -a md5 -x "61646d696e" -s "admin"
FILE=-
CMDS=!rz-hash -a md5 -x "61646d696e" -s "admin"
EXPECT=<<EOF
EOF
EXPECT_ERR=<<EOF
Hashstring already defined
EOF
RUN

NAME=rz-hash -a luhn -s "5105105105105100"
FILE=-
CMDS=!rz-hash -a luhn -s "5105105105105100"
EXPECT=<<EOF
0x00000000-0x0000000f luhn: 00
EOF
RUN

NAME=rz-hash -a luhn -s "4408041234567890"
FILE=-
CMDS=!rz-hash -a luhn -s "4408041234567890"
EXPECT=<<EOF
0x00000000-0x0000000f luhn: 07
EOF
RUN

NAME=rz-hash -L
FILE=-
CMDS=!rz-hash -L
EXPECT=<<EOF
h  md5
h  sha1
h  sha256
h  sha384
h  sha512
h  md4
h  xor
h  xorpair
h  parity
h  entropy
h  hamdist
h  pcprint
h  mod255
h  xxhash
h  adler32
h  luhn
h  crc8smbus
h  crc15can
h  crc16
h  crc16hdlc
h  crc16usb
h  crc16citt
h  crc24
h  crc32
h  crc32c
h  crc32ecma267
h  crc32bzip2
h  crc32d
h  crc32mpeg2
h  crc32posix
h  crc32q
h  crc32jamcrc
h  crc32xfer
h  crc64
h  crc64ecma
h  crc64we
h  crc64xz
h  crc64iso
h  fletcher8
h  fletcher16
h  fletcher32
h  fletcher64
e  base64
e  base91
e  punycode
c  rc2
c  rc4
c  rc6
c  aes-ecb
c  aes-cbc
c  ror
c  rol
c  rot
c  blowfish
c  cps2
c  des-ecb
c  xor
c  serpent-ecb
EOF
RUN

NAME=rz-hash -a md5 -t0x4 -x "61646d696eaa"
FILE=-
CMDS=!rz-hash -a md5 -t0x4 -x "61646d696eaa"
EXPECT=<<EOF
0x00000000-0x00000004 md5: 21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rz-hash -q -a md5 -t0x4 -x "61646d696eaa"
FILE=-
CMDS=!rz-hash -q -a md5 -t0x4 -x "61646d696eaa"
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rz-hash -q -a md5 -f0x1 -x "aa61646d696e"
FILE=-
CMDS=!rz-hash -q -a md5 -f0x1 -x "aa61646d696e"
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rz-hash -q -a md5 -i1 -x "61646d696e"
FILE=-
CMDS=!rz-hash -q -a md5 -i1 -x "61646d696e"
EXPECT=<<EOF
43442676c74ae59f219c2d87fd6bad52
EOF
RUN

NAME=rz-hash -q -a md5 -i2 -x "61646d696e"
FILE=-
CMDS=!rz-hash -q -a md5 -i2 -x "61646d696e"
EXPECT=<<EOF
9fec80fbcee7632ce78d1586332b299e
EOF
RUN

NAME=rz-hash -a md5 -t0x4 -s "admina"
FILE=-
CMDS=!rz-hash -a md5 -t0x4 -s "admina"
EXPECT=<<EOF
0x00000000-0x00000004 md5: 21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rz-hash -q -a md5 -t0x4 -s "admina"
FILE=-
CMDS=!rz-hash -q -a md5 -t0x4 -s "admina"
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rz-hash -q -a md5 -f0x1 -s "aadmin"
FILE=-
CMDS=!rz-hash -q -a md5 -f0x1 -s "aadmin"
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rz-hash -q -a md5 -i1 -s "admin"
FILE=-
CMDS=!rz-hash -q -a md5 -i1 -s "admin"
EXPECT=<<EOF
43442676c74ae59f219c2d87fd6bad52
EOF
RUN

NAME=rz-hash -q -a md5 -i2 -s "admin"
FILE=-
CMDS=!rz-hash -q -a md5 -i2 -s "admin"
EXPECT=<<EOF
9fec80fbcee7632ce78d1586332b299e
EOF
RUN

NAME=rz-hash -q -a md5 -f0x1 -t0x5 -s "aadmina"
FILE=-
CMDS=!rz-hash -q -a md5 -f0x1 -t0x5 -s "aadmina"
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rz-hash -q -a md5 -f0x1 -t0x5 -x "aa61646d696eaa"
FILE=-
CMDS=!rz-hash -q -a md5 -f0x1 -t0x5 -x "aa61646d696eaa"
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=printf "admin" | rz-hash -q -a md5 -s -
FILE=-
CMDS=!printf "admin" | rz-hash -q -a md5 -s -
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=printf "aadmina" | rz-hash -f0x1 -t0x5 -q -a md5 -s -
FILE=-
CMDS=!printf "aadmina" | rz-hash -f0x1 -t0x5 -q -a md5 -s -
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=printf "aa61646d696eaa" | rz-hash -f0x1 -t0x5 -q -a md5 -x -
FILE=-
CMDS=!printf "aa61646d696eaa" | rz-hash -f0x1 -t0x5 -q -a md5 -x -
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rz-hash -f0x1 -t0x5 -q -a md5 admin.txt
FILE=bins/other/admin.txt
CMDS=!rz-hash -f0x1 -t0x5 -q -a md5 bins/other/admin.txt
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3 bins/other/admin.txt
EOF
RUN

NAME=rz-hash -f0x1 -t0x5 -qq -a md5 admin.txt
FILE=bins/other/admin.txt
CMDS=!rz-hash -f0x1 -t0x5 -qq -a md5 bins/other/admin.txt
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rz-hash -v~commit?"
FILE=-
CMDS=!!rz-hash -v~commit?
EXPECT=<<EOF
1
EOF
RUN

NAME=rz-hash -s hello1
FILE=-
CMDS=!rz-hash -qa md5 -s hello1
EXPECT=<<EOF
203ad5ffa1d7c650ad681fdff3965cd2
EOF
RUN

NAME=rz-hash -s hello\x31
FILE=-
CMDS=!rz-hash -qa md5 -s "hello\x31"
EXPECT=<<EOF
203ad5ffa1d7c650ad681fdff3965cd2
EOF
RUN

NAME=rz-hash zero length hashes md5
FILE=-
CMDS=!rz-hash -a md5 -s ""
EXPECT=<<EOF
0x00000000-0x00000000 md5: d41d8cd98f00b204e9800998ecf8427e
EOF
RUN

NAME=rz-hash zero length hashes sha1
FILE=-
CMDS=!rz-hash -a sha1 -s ""
EXPECT=<<EOF
0x00000000-0x00000000 sha1: da39a3ee5e6b4b0d3255bfef95601890afd80709
EOF
RUN

NAME=rz-hash -c with correct expected hash
FILE=-
CMDS=!rz-hash -a md5 -s "admin" -c 21232f297a57a5a743894a0e4a801fc3
EXPECT=<<EOF
0x00000000-0x00000004 md5: 21232f297a57a5a743894a0e4a801fc3
rz-hash: Computed hash matches the expected one.
EOF
RUN

NAME=rz-hash -c with incorrect expected hash
FILE=-
CMDS=!rz-hash -a md5 -s "admin" -c 21232f297a57a5a743894a0e4a801fc4
EXPECT=<<EOF
0x00000000-0x00000004 md5: 21232f297a57a5a743894a0e4a801fc3
EOF
EXPECT_ERR=<<EOF
rz-hash: Computed hash doesn't match the expected one.
EOF
RUN

NAME=rz-hash -c with correct expected hash and quiet
FILE=-
CMDS=!rz-hash -q -a md5 -s "admin" -c 21232f297a57a5a743894a0e4a801fc3
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
rz-hash: Computed hash matches the expected one.
EOF
RUN

NAME=rz-hash -c with missing nibble
FILE=-
CMDS=!rz-hash -a md5 -s "admin" -c 21232f297a57a5a743894a0e4a801fc
EXPECT=<<EOF
EOF
EXPECT_ERR=<<EOF
rz-hash: Invalid -c hex hash
EOF
RUN

NAME=rz-hash -c with incorrect md5 hash length
FILE=-
CMDS=!rz-hash -a md5 -s "admin" -c 21232f297a57a5a743894a0e4a801f
EXPECT=<<EOF
EOF
EXPECT_ERR=<<EOF
rz-hash: Given -c hash has 15 byte(s) but the selected algorithm returns 16 byte(s).
EOF
RUN

NAME=rz-hash -c with incorrect sha1 hash length
FILE=-
CMDS=!rz-hash -a sha1 -s "admin" -c 21232f297a57a5a743894a0e4a801f
EXPECT=<<EOF
EOF
EXPECT_ERR=<<EOF
rz-hash: Given -c hash has 15 byte(s) but the selected algorithm returns 20 byte(s).
EOF
RUN

NAME=rz-hash -c with 2 hash algorithms
FILE=-
CMDS=!rz-hash -a md5,sha1 -s "admin" -c 21232f297a57a5a743894a0e4a801f
EXPECT=<<EOF
EOF
EXPECT_ERR=<<EOF
rz-hash: Option -c incompatible with multiple algorithms in -a.
EOF
RUN

NAME=rz-hash -c with all hash algorithms
FILE=-
CMDS=!rz-hash -a all -s "admin" -c 21232f297a57a5a743894a0e4a801f
EXPECT=<<EOF
EOF
EXPECT_ERR=<<EOF
rz-hash: Option -c incompatible with multiple algorithms in -a.
EOF
RUN

NAME=rz-hash -c with custom block size and per-block hash
FILE=-
CMDS=!rz-hash -b 1 -B -s "admin" -c 21232f297a57a5a743894a0e4a801f
EXPECT=<<EOF
EOF
EXPECT_ERR=<<EOF
rz-hash: Option -c incompatible with -b and -B options.
EOF
RUN

NAME=rz-hash -c with base64 encoding
FILE=-
CMDS=!rz-hash -E base64 -s "admin" -c 21232f297a57a5a743894a0e4a801f
EXPECT=<<EOF
EOF
EXPECT_ERR=<<EOF
rz-hash: Option -c incompatible with -E base64, -E base91, -D base64 or -D base91 options.
EOF
RUN

NAME=rz-hash -c with base64 decoding
FILE=-
CMDS=!rz-hash -D base64 -s "admin" -c 21232f297a57a5a743894a0e4a801f
EXPECT=<<EOF
EOF
EXPECT_ERR=<<EOF
rz-hash: Option -c incompatible with -E base64, -E base91, -D base64 or -D base91 options.
EOF
RUN

# Taken from "Descriptions of SHA-256, SHA-384, and SHA-512" by NIST
NAME=rz-hash of "abc" using sha256
FILE=-
CMDS=!rz-hash -a sha256 -s "abc"
EXPECT=<<EOF
0x00000000-0x00000002 sha256: ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
EOF
RUN

# Taken from "Descriptions of SHA-256, SHA-384, and SHA-512" by NIST
NAME=rz-hash of "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" using sha256
FILE=-
CMDS=!rz-hash -a sha256 -s "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
EXPECT=<<EOF
0x00000000-0x00000037 sha256: 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1
EOF
RUN

# Taken from "Descriptions of SHA-256, SHA-384, and SHA-512" by NIST
NAME=rz-hash of "abc" using sha512
FILE=-
CMDS=!rz-hash -a sha512 -s "abc"
EXPECT=<<EOF
0x00000000-0x00000002 sha512: ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f
EOF
RUN

# Taken from "Descriptions of SHA-256, SHA-384, and SHA-512" by NIST
NAME=rz-hash of "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" using sha512
FILE=-
CMDS=!rz-hash -a sha512 -s "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
EXPECT=<<EOF
0x00000000-0x0000006f sha512: 8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909
EOF
RUN

# Taken from "Descriptions of SHA-256, SHA-384, and SHA-512" by NIST3
NAME=rz-hash of "abc" using sha384
FILE=-
CMDS=!rz-hash -a sha384 -s "abc"
EXPECT=<<EOF
0x00000000-0x00000002 sha384: cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7
EOF
RUN

# Taken from "Descriptions of SHA-256, SHA-384, and SHA-512" by NIST
NAME=rz-hash of "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" using sha384
FILE=-
CMDS=!rz-hash -a sha384 -s "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
EXPECT=<<EOF
0x00000000-0x0000006f sha384: 09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039
EOF
RUN

NAME=rz-hash of empty string using sha256
FILE=-
CMDS=!rz-hash -a sha256 -s ""
EXPECT=<<EOF
0x00000000-0x00000000 sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
EOF
RUN

NAME=rz-hash of empty string using sha384
FILE=-
CMDS=!rz-hash -a sha384 -s ""
EXPECT=<<EOF
0x00000000-0x00000000 sha384: 38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b
EOF
RUN

NAME=rz-hash of empty string using sha512
FILE=-
CMDS=!rz-hash -a sha512 -s ""
EXPECT=<<EOF
0x00000000-0x00000000 sha512: cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e
EOF
RUN

NAME=rz-hash -E RC4
FILE=-
CMDS=!rz-hash -S key -E rc4 -s hello" world\n" | rz-hash -S key -E rc4 -s -
EXPECT=<<EOF
hello world
EOF
RUN

NAME=rz-hash -E xor
FILE=-
CMDS=!rz-hash -S key -E xor -s hello" world\n" | rz-hash -S key -E xor -s -
EXPECT=<<EOF
hello world
EOF
RUN

NAME=rz-hash -E blowfish
FILE=-
CMDS=!rz-hash -S key -E blowfish -s hello" world 123\n" | rz-ax -S
EXPECT=<<EOF
6ceced43fb2a72c9aa9447d193b00763
EOF
RUN

NAME=rz-hash -D blowfish
FILE=-
CMDS=!rz-hash -S key -E blowfish -s hello" world 123\n" | rz-hash -S key -D blowfish -s -
EXPECT=<<EOF
hello world 123
EOF
RUN

NAME=rz-hash -E aes-ecb 128 bit
FILE=-
CMDS=!rz-hash -E aes-ecb -S "11111111111111111111111111111111" -s "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") <(echo -en "\xff\x6f\xb5\xd9\x27\x6d\xe8\x38\x8e\x4b\x82\xa7\x73\xd0\xb5\x21\xff\x6f\xb5\xd9\x27\x6d\xe8\x38\x8e\x4b\x82\xa7\x73\xd0\xb5\x21\xff\x6f\xb5\xd9\x27\x6d\xe8\x38\x8e\x4b\x82\xa7\x73\xd0\xb5\x21\xff\x6f\xb5\xd9\x27\x6d\xe8\x38\x8e\x4b\x82\xa7\x73\xd0\xb5\x21")"
EXPECT=<<EOF
EOF
RUN

NAME=rz-hash -D aes-ecb 128 bit
FILE=-
CMDS=!rz-hash -E aes-ecb -S "11111111111111111111111111111111" -s "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" | rz-hash -D aes-ecb -S "11111111111111111111111111111111" -s -
EXPECT=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
RUN

NAME=rz-hash -E aes-ecb 192 bit
FILE=-
CMDS=!rz-hash -E aes-ecb -S 8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b -x "6bc1bee22e409f96e93d7e117393172a" | rz-ax -S
EXPECT=<<EOF
bd334f1d6e45f25ff712a214571fa5cc
EOF
RUN

NAME=rz-hash -D aes-ecb 192 bit
FILE=-
CMDS=!rz-hash -E aes-ecb -S 8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b -x "6bc1bee22e409f96e93d7e117393172a" | rz-hash -D aes-ecb -S 8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b -s - | rz-ax -S
EXPECT=<<EOF
6bc1bee22e409f96e93d7e117393172a
EOF
RUN

NAME=rz-hash -E aes-ecb 256 bit
FILE=-
CMDS=!rz-hash -E aes-ecb -S 603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4 -x "6bc1bee22e409f96e93d7e117393172a" | rz-ax -S
EXPECT=<<EOF
f3eed1bdb5d2a03c064b5a7e3db181f8
EOF
RUN

NAME=rz-hash -D aes-ecb 256 bit
FILE=-
CMDS=!rz-hash -E aes-ecb -S 603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4 -x "6bc1bee22e409f96e93d7e117393172a" | rz-hash -D aes-ecb -S 603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4 -s - | rz-ax -S
EXPECT=<<EOF
6bc1bee22e409f96e93d7e117393172a
EOF
RUN

NAME=rz-hash -E aes-cbc 128 bit
FILE=-
CMDS=!rz-hash -E aes-cbc -S "2b7e151628aed2a6abf7158809cf4f3c" -I "7649ABAC8119B246CEE98E9B12E9197D"  -x "ae2d8a571e03ac9c9eb76fac45af8e51" | rz-ax -S
EXPECT=<<EOF
5086cb9b507219ee95db113a917678b2
EOF
RUN

NAME=rz-hash -D aes-cbc 128 bit
FILE=-
CMDS=!rz-hash -E aes-cbc -S "2b7e151628aed2a6abf7158809cf4f3c" -I "7649ABAC8119B246CEE98E9B12E9197D"  -x "ae2d8a571e03ac9c9eb76fac45af8e51" | rz-hash -D aes-cbc -S "2b7e151628aed2a6abf7158809cf4f3c" -I "7649ABAC8119B246CEE98E9B12E9197D" -s - | rz-ax -S
EXPECT=<<EOF
ae2d8a571e03ac9c9eb76fac45af8e51
EOF
RUN

NAME=rz-hash -E aes-cbc 192 bit
FILE=-
CMDS=!rz-hash -E aes-cbc -S 8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b -x "6bc1bee22e409f96e93d7e117393172a" -I "000102030405060708090A0B0C0D0E0F" | rz-ax -S
EXPECT=<<EOF
4f021db243bc633d7178183a9fa071e8
EOF
RUN

NAME=rz-hash -D aes-cbc 192 bit
FILE=-
CMDS=!rz-hash -E aes-cbc -S 8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b -x "6bc1bee22e409f96e93d7e117393172a" -I "000102030405060708090A0B0C0D0E0F" | rz-hash -D aes-cbc -S 8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b -I "000102030405060708090A0B0C0D0E0F" -s - | rz-ax -S
EXPECT=<<EOF
6bc1bee22e409f96e93d7e117393172a
EOF
RUN

NAME=rz-hash -E aes-cbc 256 bit
FILE=-
CMDS=!rz-hash -E aes-cbc -S 603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4 -x "f69f2445df4f9b17ad2b417be66c3710" -I "39F23369A9D9BACFA530E26304231461" | rz-ax -S
EXPECT=<<EOF
b2eb05e2c39be9fcda6c19078c6a9d1b
EOF
RUN

NAME=rz-hash -D aes-cbc 256 bit
FILE=-
CMDS=!rz-hash -E aes-cbc -S 603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4 -x "f69f2445df4f9b17ad2b417be66c3710" -I "39F23369A9D9BACFA530E26304231461" | rz-hash -D aes-cbc -S 603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4 -I "39F23369A9D9BACFA530E26304231461" -s - | rz-ax -S
EXPECT=<<EOF
f69f2445df4f9b17ad2b417be66c3710
EOF
RUN

NAME=rz-hash -E rot
FILE=-
CMDS=!rz-hash -E rot -S s:13 -s hello" world\n"
EXPECT=<<EOF
uryyb jbeyq
EOF
RUN

NAME=rz-hash -E rot negative key
FILE=-
CMDS=!rz-hash -E rot -S s:14 -s hello" world\n" | rz-hash -E rot -S s:-14 -s -
EXPECT=<<EOF
hello world
EOF
RUN

NAME=rz-hash -E rol
FILE=-
CMDS=!rz-hash -E rol -S 03 -x "31ed4989" | rz-ax -S
EXPECT=<<EOF
896f4a4c
EOF
RUN

NAME=rz-hash -E ror
FILE=-
CMDS=!rz-hash -E ror -S 04 -x "62da9212" | rz-ax -S
EXPECT=<<EOF
26ad2921
EOF
RUN

NAME=rz-hash -E base91
FILE=-
CMDS=!rz-hash -E base91 -s "hello world\n"
EXPECT=TPwJh>Io2Tv!^aB
RUN

NAME=rz-hash -D base91
FILE=-
CMDS=!rz-hash -E base91 -s "hello world" | rz-hash -D base91 -s -
EXPECT=hello world
RUN

NAME=rz-hash -E rc2
FILE=-
CMDS=!rz-hash -E rc2 -S key -s "helloworld123456" | rz-ax -S 
EXPECT=<<EOF
a9c85c7650456d8f5f369704ad1e339f
EOF
RUN

NAME=rz-hash -D rc2
FILE=-
CMDS=!rz-hash -E rc2 -S key -s "helloworld123456" | rz-hash -D rc2 -S key -s -
EXPECT=helloworld123456
RUN

NAME=rz-hash -E punycode
FILE=-
CMDS=!rz-hash -E punycode -x 57696c6c73742064752064696520426cc3bc74686520646573206672c3bc68656e2c20646965204672c3bc6368746520646573207370c3a4746572656e204a6168726573
EXPECT=Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal
RUN

NAME=rz-hash -D punycode
FILE=-
CMDS=!rz-hash -D punycode -s "Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal" | rz-ax -S
EXPECT=<<EOF
57696c6c73742064752064696520426cc3bc74686520646573206672c3bc68656e2c20646965204672c3bc6368746520646573207370c3a4746572656e204a6168726573
EOF
RUN

NAME=rz-hash -E punycode[1]
FILE=-
CMDS=!rz-hash -E punycode -x f09f918d
EXPECT=yp8h
RUN

NAME=rz-hash -D punycode[1]
FILE=-
CMDS=!rz-hash -D punycode -s yp8h | rz-ax -S
EXPECT=<<EOF
f09f918d
EOF
RUN

NAME=rz-hash -E rc6 128 bit
FILE=-
CMDS=!rz-hash -E rc6 -S 0123456789abcdef0112233445566778 -x 02132435465768798a9bacbdcedfe0f1 | rz-ax -S
EXPECT=<<EOF
524e192f4715c6231f51f6367ea43f18
EOF
RUN

NAME=rz-hash -D rc6 128 bit
FILE=-
CMDS=!rz-hash -D rc6 -S 0123456789abcdef0112233445566778 -x 524e192f4715c6231f51f6367ea43f18 | rz-ax -S
EXPECT=<<EOF
02132435465768798a9bacbdcedfe0f1
EOF
RUN

NAME=rz-hash -E rc6 192 bit
FILE=-
CMDS=!rz-hash -E rc6 -S 0123456789abcdef0112233445566778899aabbccddeeff0 -x 02132435465768798a9bacbdcedfe0f1 | rz-ax -S
EXPECT=<<EOF
688329d019e505041e52e92af95291d4
EOF
RUN

NAME=rz-hash -D rc6 192 bit
FILE=-
CMDS=!rz-hash -D rc6 -S 0123456789abcdef0112233445566778899aabbccddeeff0 -x 688329d019e505041e52e92af95291d4 | rz-ax -S
EXPECT=<<EOF
02132435465768798a9bacbdcedfe0f1
EOF
RUN

NAME=rz-hash -E rc6 256 bit
FILE=-
CMDS=!rz-hash -E rc6 -S 0123456789abcdef0112233445566778899aabbccddeeff01032547698badcfe -x 02132435465768798a9bacbdcedfe0f1 | rz-ax -S
EXPECT=<<EOF
c8241816f0d7e48920ad16a1674e5d48
EOF
RUN

NAME=rz-hash -D rc6 256 bit
FILE=-
CMDS=!rz-hash -D rc6 -S 0123456789abcdef0112233445566778899aabbccddeeff01032547698badcfe -x c8241816f0d7e48920ad16a1674e5d48 | rz-ax -S
EXPECT=<<EOF
02132435465768798a9bacbdcedfe0f1
EOF
RUN

NAME=rz-hash -E cps2
FILE=-
CMDS=!rz-hash -E cps2 -S "0x942a5702 0x05ac140e" -x 000000000000033244d31b9deba90ac1 | rz-ax -S
EXPECT=<<EOF
d5642832bc24ac560000fe020000fe02
EOF
RUN

NAME=rz-hash -D cps2
FILE=-
CMDS=!rz-hash -D cps2 -S "0x942a5702 0x05ac140e" -x d5642832bc24ac560000fe020000fe02 | rz-ax -S
EXPECT=<<EOF
000000000000033244d31b9deba90ac1
EOF
RUN

NAME=rz-hash -E des-ecb
FILE=-
CMDS=!rz-hash -E "des-ecb" -S "4545454545454545" -x "CC3368EE3DD10A86" | rz-ax -S
EXPECT=<<EOF
4545454545454545
EOF
RUN

NAME=rz-hash -D des-ecb
FILE=-
CMDS=!rz-hash -D "des-ecb" -S "0101010101010101" -x "41AD068548809D02994D4DC157B96C52" | rz-ax -S
EXPECT=<<EOF
b01c29502b59ff4a0101010101010101
EOF
RUN

NAME=rz-hash -E des-ecb STRING
FILE=-
CMDS=!rz-hash -E "des-ecb" -S s:"doom bin" -s "A password storms below a laid singer." | rz-ax -S
EXPECT=<<EOF
8d244873a8e0de1287f65d712419cb937ff318a5352682e0c31d3e7a72c7e35f40c06d63fb5f2e5f
EOF
RUN

NAME=rz-hash -D des-ecb STRING
FILE=-
CMDS=!rz-hash -D "des-ecb" -S s:"savethat" -x "c3868da6e3d787c88e5a61a7c333cd802e5cee17d7b09555572a35e120fb8e36dc9f0722976934b9453a3a4e741f27c8"
EXPECT=How does a passionate magic wipe a reactionary?.
RUN

NAME=rz-hash -E serpent-ecb 128 bit
FILE=-
CMDS=!rz-hash -E serpent-ecb -S "BFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBF" -x "BFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBF" | rz-ax -S
EXPECT=<<EOF
af39614e747b9331c38b797f527ebea6
EOF
RUN

NAME=rz-hash -D serpent-ecb 128 bit
FILE=-
CMDS=!rz-hash -D serpent-ecb -S "2BD6459F82C5B300952C49104881FF48" -x "EA024714AD5C4D84EA024714AD5C4D84" | rz-ax -S
EXPECT=<<EOF
beb6c069393822d3be73ff30525ec43e
EOF
RUN

NAME=rz-hash -E serpent-ecb 192 bit
FILE=-
CMDS=!rz-hash -E serpent-ecb -S "C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C7" -x "C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C7" | rz-ax -S
EXPECT=<<EOF
844a4ef08b4354c52593d3e907a163f7
EOF
RUN

NAME=rz-hash -D serpent-ecb 192 bit
FILE=-
CMDS=!rz-hash -D serpent-ecb -S "2BD6459F82C5B300952C49104881FF482BD6459F82C5B300" -x "EA024714AD5C4D84EA024714AD5C4D84" | rz-ax -S
EXPECT=<<EOF
e0208be278e21420c4b1b9747788a954
EOF
RUN

NAME=rz-hash -E serpent-ecb 256 bit
FILE=-
CMDS=!rz-hash -E serpent-ecb -S "5757575757575757575757575757575757575757575757575757575757575756" -x "57575757575757575757575757575756" | rz-ax -S
EXPECT=<<EOF
d35588cf3d2e74f2a0df437ffa0073b3
EOF
RUN

NAME=rz-hash -D serpent-ecb 256 bit
FILE=-
CMDS=!rz-hash -D serpent-ecb -S "2BD6459F82C5B300952C49104881FF482BD6459F82C5B300952C49104881FF48" -x "EA024714AD5C4D84EA024714AD5C4D84" | rz-ax -S
EXPECT=<<EOF
677c8dfaa08071743fd2b415d1b28af2
EOF
RUN

NAME=rz-hash -E serpent-ecb zero padding
FILE=-
CMDS=!rz-hash -E serpent-ecb -S "1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe" -x "101231" | rz-ax -S
EXPECT=<<EOF
417dfc518e8146ea81b089731b56fefa
EOF
RUN

NAME=rz-hash -a fletcher8 -s hello-world
FILE=-
CMDS=!rz-hash -a fletcher8 -s hello-world
EXPECT=<<EOF
0x00000000-0x0000000a fletcher8: 6d
EOF
RUN

NAME=rz-hash -a fletcher16 -s hello-world
FILE=-
CMDS=!rz-hash -a fletcher16 -s hello-world
EXPECT=<<EOF
0x00000000-0x0000000a fletcher16: 6d68
EOF
RUN

NAME=rz-hash -a fletcher32 -s hello-world
FILE=-
CMDS=!rz-hash -a fletcher32 -s hello-world
EXPECT=<<EOF
0x00000000-0x0000000a fletcher32: 91dbfc5b
EOF
RUN

NAME=rz-hash -a fletcher64 -s hello-world
FILE=-
CMDS=!rz-hash -a fletcher64 -s hello-world
EXPECT=<<EOF
0x00000000-0x0000000a fletcher64: 49ff47dc88f79724
EOF
RUN

NAME=rz-hash empty single path
FILE=-
CMDS=!rz-hash -a md5 ""
EXPECT_ERR=<<EOF
Cannot open empty path
EOF
RUN

NAME=rz-hash empty second path
FILE=-
CMDS=!rz-hash -a md5 bins/elf/analysis/hello-linux-x86_64 ""
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: 0x00000000-0x00001a35 md5: c957bd5bd6204470256bc15248ccafd4
EOF
EXPECT_ERR=<<EOF
Cannot open empty path
EOF
RUN

NAME=rz-hash empty first file
FILE=-
CMDS=!rz-hash -a md5 "" bins/elf/analysis/hello-linux-x86_64
EXPECT_ERR=<<EOF
Cannot open empty path
EOF
RUN

NAME=rz-hash -j file
FILE=-
CMDS=!rz-hash -j -a md4,md5 bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
[{"name":"md5","hash":"c957bd5bd6204470256bc15248ccafd4"},{"name":"md4","hash":"d4d61472a12d59be3a85e07ff9065658"}]
EOF
RUN

NAME=rz-hash -j string
FILE=-
CMDS=!rz-hash -j -a sha1,sha256 -s 233
EXPECT=<<EOF
[{"name":"sha1","hash":"52fdb9f68c503e11d168fe52035901864c0a4861"},{"name":"sha256","hash":"c0509a487a18b003ba05e505419ebb63e57a29158073e381f57160b5c5b86426"}]
EOF
RUN
