Ripemd128

Constructors

this
this()

Construct a Ripemd128

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 Ripemd128 digest is 16 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(const(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 [@property getter]

Length padding size

padMessage
void padMessage(ubyte[] data)

Pads the digest data

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

Performs the length padding

transform
void transform(const(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(const(ubyte[]) input, uint[] output)

Converts 8 bit to 32 bit Little Endian

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

Converts 8 bit to 32 bit Big Endian

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

Converts 8 bit to 64 bit Little Endian

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

Converts 8 bit to 64 bit Big Endian

rotateLeft
uint rotateLeft(uint x, uint n)

Rotate left by n

Examples

__gshared immutable immutable(char)[][] strings =
[
        "",
        "a",
        "abc",
        "message digest",
        "abcdefghijklmnopqrstuvwxyz",
        "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
        "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
];

__gshared immutable immutable(char)[][] results =
[
        "cdf26213a150dc3ecb610f18f6b38b46",
        "86be7afa339d0fc7cfc785e72f578d33",
        "c14a12199c66e4ba84636b0f69144c77",
        "9e327b3d6e523062afc1132d7df9d1b8",
        "fd2aa607f71dc8f510714922b371834e",
        "a1aa0689d0fafa2ddc22e88b49133a06",
        "d1e959eb179c911faea4624c60c5c702",
        "3f45ef194732c2dbb2c4a2c769795fa3"
];

Ripemd128 h = new Ripemd128();

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

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

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

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

Meta