Ripemd256

Constructors

this
this()

Construct a Ripemd256

Members

Functions

addSize
uint addSize()

Length padding size

blockSize
uint blockSize()

block size

createDigest
void createDigest(ubyte[] buf)

Obtain the digest

digestSize
uint digestSize()

The size of a Ripemd256 digest is 32 bytes

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

Performs the length padding

padMessage
void padMessage(ubyte[] at)

Pads the cipher data

reset
void reset()

Initialize the cipher

transform
void transform(ubyte[] input)

Performs the cipher on a block of data

Inherited Members

From MerkleDamgard

createDigest
void createDigest(ubyte[] buf)

Constructs the digest

blockSize
uint blockSize()

Digest block size

addSize
uint addSize()

Length padding size

padMessage
void padMessage(ubyte[] data)

Pads the digest data

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

Performs the length padding

transform
void transform(ubyte[] data)

Performs the digest on a block of data

extend
void extend()

Final processing of digest.

reset
void reset()

Initialize the digest

update
MerkleDamgard update(const(void)[] input)

Digest additional data

binaryDigest
ubyte[] binaryDigest(ubyte[] buf)

Complete the digest

littleEndian32
void littleEndian32(ubyte[] input, uint[] output)

Converts 8 bit to 32 bit Little Endian

bigEndian32
void bigEndian32(ubyte[] input, uint[] output)

Converts 8 bit to 32 bit Big Endian

littleEndian64
void littleEndian64(ubyte[] input, ulong[] output)

Converts 8 bit to 64 bit Little Endian

bigEndian64
void bigEndian64(ubyte[] input, ulong[] output)

Converts 8 bit to 64 bit Big Endian

rotateLeft
uint rotateLeft(uint x, uint n)

Rotate left by n

Examples

static istring[] strings =
[
        "",
        "a",
        "abc",
        "message digest",
        "abcdefghijklmnopqrstuvwxyz",
        "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
        "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
];

static istring[] results =
[
        "02ba4c4e5f8ecd1877fc52d64d30e37a2d9774fb1e5d026380ae0168e3c5522d",
        "f9333e45d857f5d90a91bab70a1eba0cfb1be4b0783c9acfcd883a9134692925",
        "afbd6e228b9d8cbbcef5ca2d03e6dba10ac0bc7dcbe4680e1e42d2e975459b65",
        "87e971759a1ce47a514d5c914c392c9018c7c46bc14465554afcdf54a5070c0e",
        "649d3034751ea216776bf9a18acc81bc7896118a5197968782dd1fd97d8d5133",
        "3843045583aac6c8c8d9128573e7a9809afb2a0f34ccc36ea9e72f16f6368e3f",
        "5740a408ac16b720b84424ae931cbb1fe363d1d0bf4017f1a89f7ea6de77a0b8",
        "06fdcc7a409548aaf91368c06a6275b553e3f099bf0ea4edfd6778df89a890dd"
];

Ripemd256 h = new Ripemd256();

foreach (i, s; strings)
{
    h.update(cast(ubyte[]) s);
    char[] d = h.hexDigest;

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

char[] s = new char[1000000];
for (auto i = 0; i < s.length; i++) s[i] = 'a';
auto result = "ac953744e10e31514c150d4d8d7b677342e33399788296e43ae4850ce4f97978";
h.update(cast(ubyte[]) s);
auto d = h.hexDigest;

test(d == result,":(1 million times \"a\")("~d~")!=("~result~")");

Meta