Construct a Sha1 hash algorithm context
Performs the cipher on a block of data
The digest size of Sha-0 and Sha-1 is 20 bytes
Initialize the cipher
Obtain the digest
block size
Length padding size
Pads the cipher data
Performs the length padding
__gshared immutable immutable(char)[][] strings = [ "abc", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "a", "0123456701234567012345670123456701234567012345670123456701234567" ]; __gshared immutable immutable(char)[][] results = [ "a9993e364706816aba3e25717850c26c9cd0d89d", "84983e441c3bd26ebaae4aa1f95129e5e54670f1", "34aa973cd4c4daa4f61eeb2bdbad27316534016f", "dea356a2cddd90c7a7ecedc5ebb563934f460452" ]; __gshared immutable int[] repeat = [ 1, 1, 1000000, 10 ]; Sha1 h = new Sha1(); foreach (int i, immutable(char)[] s; strings) { for(int r = 0; r < repeat[i]; r++) h.update(s); char[] d = h.hexDigest(); assert(d == results[i],":("~s~")("~d~")!=("~results[i]~")"); }