adjust the byte counts so that byteCount2 represents the upper long (less 3 bits) word of the byte count.
Calculate the final hash value.
Reset the digest to its initial state. It is not necessary to call start after finish or doFinal.
testing SHA256 algorithm
1 t { 2 3 immutable string[] plaintexts = [ 4 x"", 5 x"", // twice the same to test start() 6 x"616263", 7 "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" 8 9 ]; 10 11 immutable string[] hexHashes = [ 12 x"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 13 x"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 14 x"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", 15 x"cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1" 16 ]; 17 18 testDigest(new SHA256Digest, plaintexts, hexHashes
testing SHA384 algorithm
1 t { 2 3 immutable string[] plaintexts = [ 4 x"", 5 x"", // twice the same to test start() 6 x"616263", 7 "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", 8 9 ]; 10 11 immutable string[] hexHashes = [ 12 x"38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b", 13 x"38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b", 14 x"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7", 15 x"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039" 16 ]; 17 18 testDigest(new SHA384Digest, plaintexts, hexHashes
testing SHA512 algorithm
1 t { 2 3 immutable string[] plaintexts = [ 4 x"", 5 x"", // twice the same to test start() 6 x"616263", 7 "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" 8 ]; 9 10 immutable string[] hexHashes = [ 11 x"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e", 12 x"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e", 13 x"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f", 14 x"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909" 15 ]; 16 17 18 testDigest(new SHA512Digest, plaintexts, hexHashes