Sha1

Constructors

this
this()

Construct a Sha1 hash algorithm context

Members

Functions

transform
void transform(const(ubyte[]) input)

Performs the cipher on a block of data

Static functions

expand
void expand(uint[] W, uint s)

Inherited Members

From Sha01

context
uint[5] context;
Undocumented in source.
mask
enum uint mask;
Undocumented in source.
digestSize
uint digestSize()

The digest size of Sha-0 and Sha-1 is 20 bytes

reset
void reset()

Initialize the cipher

createDigest
void createDigest(ubyte[] buf)

Obtain the digest

blockSize
uint blockSize()

block size

addSize
uint addSize()

Length padding size

padMessage
void padMessage(ubyte[] data)

Pads the cipher data

padLength
void padLength(ubyte[] data, ulong length)

Performs the length padding

f
uint f(uint t, uint B, uint C, uint D)
K
uint[] K;

Examples

__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]~")");
        }

Meta