RIPEMD is a message digest/hash algorithm with a digest/hash size of 128 bits (16 characters), 160 bits (20 characters), 256 bits (32 characters) or 320 bits (40 characters)
RIPEMD-256 and RIPEMD-320 are optional extensions of, respectively, RIPEMD-128 and RIPEMD-160, and are intended for applications of hash functions that require a longer hash result without needing a larger security level.
Some applications of hash functions require a longer hash result without needing a larger security level. To this end RIPEMD-256 and RIPEMD-320 are constructed from, respectively, RIPEMD-128 and RIPEMD-160 by initialising the two parallel lines with different initial values, omitting the combination of the two lines at the end of every application of the compression function, and exchanging a chaining variable between the 2 parallel lines after each round. Remark that the security level of the 320-bit extension of RIPEMD-160 is only guaranteed to be the same as that of RIPEMD-160 itself, and similarly for the 256-bit extension of RIPEMD-128 with respect to RIPEMD-128 itself.
This algorithm has been tested against official test vectors.
Object
RIPEMD
class RIPEMD implements
IHashAlgorithm
Constructors
RIPEMD | Constructor that takes number of bits to use. |
Methods
Final | Use this function when you are done adding bytes to the RIPEMD class. |
Update | Use this method to add data with MemoryBlock to the RIPEMD stream. |
Update | Use this method to add data with String to the RIPEMD stream. |
Constants
Bits_128 = 128 | Constant that specifies 128 bits. This constant can be passed into the RIPEMD constructor. |
Bits_160 = 160 | Constant that specifies 160 bits. This constant can be passed into the RIPEMD constructor. |
Bits_256 = 256 | Constant that specifies 256 bits. This constant can be passed into the RIPEMD constructor. |
Bits_320 = 320 | Constant that specifies 320 bits. This constant can be passed into the RIPEMD constructor. |
Test case for known test vector
Dim data as String
Dim hash as RIPEMD
Dim result as String
Dim hexResult as String
Dim i as Integer
data = "a"
// We do this in ASCII because the well known test vectors come in ASCII
data = ConvertEncoding(data,Encodings.ASCII)
hash = new RIPEMD(RIPEMD.Bits_128)
hash.Update(data)
result = hash.Final()
// Convert to HEX
For i = 1 to 16
hexResult = hexResult + Right("0"+Hex(Asc(Mid(result,i,1))),2)
next
if hexResult <> Uppercase("86be7afa339d0fc7cfc785e72f578d33") then
return false
end if
// Lets test another official vector
data = "a"
// We do this in ASCII because the well known test vectors come in ASCII
data = ConvertEncoding(data,Encodings.ASCII)
hash = new RIPEMD(RIPEMD.Bits_128)
for i = 1 to 1000000
hash.Update(data)
next
result = hash.Final()
hexResult = ""
// Convert to HEX
For i = 1 to 16
hexResult = hexResult + Right("0"+Hex(Asc(Mid(result,i,1))),2)
next
if hexResult <> Uppercase("4a7f5723f954eba1216c9d8f6320431f") then
return false
end if
// Lets test another official vector
data = "1234567890"
// We do this in ASCII because the well known test vectors come in ASCII
data = ConvertEncoding(data,Encodings.ASCII)
hash = new RIPEMD(RIPEMD.Bits_128)
for i = 1 to 8//1000000
hash.Update(data)
next
result = hash.Final()
hexResult = ""
// Convert to HEX
For i = 1 to 16
hexResult = hexResult + Right("0"+Hex(Asc(Mid(result,i,1))),2)
next
if hexResult = Uppercase("3f45ef194732c2dbb2c4a2c769795fa3") then
return true
else
return false
end if
Supported Platforms:
MacOS X Cocoa 32 bitMacOS X Cocoa 64 bitWindows 32 bitWindows 64 bitLinux 32 bitLinux 64 bitLinux ARMUnsupported Platforms:
MacOS X Carbon