Ripemd320

Constructors

this
this()

Construct a Ripemd320

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 Ripemd320 digest is 40 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

Unittests

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

static istring[] results = [
    "22d65d5661536cdc75c1fdf5c6de7b41b9f27325ebc61e8557177d705a0ec880151c3a32a00899b8",
    "ce78850638f92658a5a585097579926dda667a5716562cfcf6fbe77f63542f99b04705d6970dff5d",
    "de4c01b3054f8930a79d09ae738e92301e5a17085beffdc1b8d116713e74f82fa942d64cdbc4682d",
    "3a8e28502ed45d422f68844f9dd316e7b98533fa3f2a91d29f84d425c88d6b4eff727df66a7c0197",
    "cabdb1810b92470a2093aa6bce05952c28348cf43ff60841975166bb40ed234004b8824463e6b009",
    "d034a7950cf722021ba4b84df769a5de2060e259df4c9bb4a4268c0e935bbc7470a969c9d072a1ac",
    "ed544940c86d67f250d232c30b7b3e5770e0c60c8cb9a4cafe3b11388af9920e1b99230b843c86a4",
    "557888af5f6d8ed62ab66945c6d2a0a47ecd5341e915eb8fea1d0524955f825dc717e4a008ab2d42"
];

Ripemd320 h = new Ripemd320();

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 = "bdee37f4371e20646b8b0d862dda16292ae36f40965e8c8509e63d1dbddecc503e2b63eb9245bb66";
h.update(cast(ubyte[]) s);
auto d = h.hexDigest;

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

Meta