e-CryptIt Engine REALbasic Plugin

RIPEMD_160 Class

RIPEMD-160 (RACE Integrity Primitives Evaluation Message Digest) is a 160-bit message digest algorithm (and cryptographic hash function) developed in Europe by Hans Dobbertin, Antoon Bosselaers and Bart Preneel, and first published in 1996 . It is an improved version of RIPEMD, which in turn was based upon the design principles used in MD4, and is similar in performance to the more popular SHA-1.

RIPEMD-160 is a message digest/hash algorithm with a digest/hash size of 160 bits (20 characters).

This algorithm has been tested against official test vectors.

Object
   RIPEMD_160

class RIPEMD_160 implements

IHashAlgorithm

Methods

FinalUse this function when you are done adding bytes to the RIPEMD_160 class.
UpdateUse this method to add data to the RIPEMD_160 stream.

Test case for a known test vector


Dim data as String
Dim hash as RIPEMD_160
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_160()

hash.Update(data)

result = hash.Final()

// Convert to HEX
For i = 1 to 20
    hexResult = hexResult + Right("0"+Hex(Asc(Mid(result,i,1))),2)
next

if hexResult <> Uppercase("0bdc9d2d256b3ee9daae347be6f4dc835a467ffe") 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_160()

for i = 1 to 1000000
    hash.Update(data)
next

result = hash.Final()

hexResult = ""
// Convert to HEX
For i = 1 to 20
    hexResult = hexResult + Right("0"+Hex(Asc(Mid(result,i,1))),2)
next

if hexResult <> Uppercase("52783243c1697bdbe16d37f97f68f08325dc1528") 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_160()

for i = 1 to 8//1000000
    hash.Update(data)
next

result = hash.Final()

hexResult = ""
// Convert to HEX
For i = 1 to 20
    hexResult = hexResult + Right("0"+Hex(Asc(Mid(result,i,1))),2)
next

if hexResult = Uppercase("9b752e45573d4b39f4dbd3323cab82bf63326bfb") then
    return true
else
    return false
end if

Supported Platforms:

  • PPC - MacOS 9
  • Carbon - MacOS 9 and MacOS X (PEF)
  • MacOS X PPC - (Mach-O)
  • MacOS X Universal Binary (Mach-O)
  • Win32 - Windows
  • Linux x86