Sha1

Constructors

this
this()

Construct a Sha1 hash algorithm context

Members

Functions

transform
void transform(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
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

transform
void transform(ubyte[] data)

To be implemented

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, size_t length)

Performs the length padding

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

Examples

static istring[] strings = [
        "abc",
        "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
        "a",
        "0123456701234567012345670123456701234567012345670123456701234567"
];

static istring[] results = [
        "a9993e364706816aba3e25717850c26c9cd0d89d",
        "84983e441c3bd26ebaae4aa1f95129e5e54670f1",
        "34aa973cd4c4daa4f61eeb2bdbad27316534016f",
        "dea356a2cddd90c7a7ecedc5ebb563934f460452"
];

static int[] repeat = [
        1,
        1,
        1000000,
        10
];

Sha1 h = new Sha1();

foreach (i, s; strings)
{
    for(int r = 0; r < repeat[i]; r++)
        h.update(s);

    char[] d = h.hexDigest();
    test(d == results[i],":("~s~")("~d~")!=("~results[i]~")");
}

Meta