| e-CryptIt Engine REALbasic Plugin |
|
RIPEMD_128 Class
RIPEMD_128 is a message digest/hash algorithm with a digest/hash size of 128 bits (16 characters).
This algorithm has been tested against official test vectors.
Object
RIPEMD_128
class RIPEMD_128 implements
IHashAlgorithm
Methods
Final | Use this function when you are done adding bytes to the RIPEMD_128 class. |
Update | Use this method to add data to the RIPEMD_128 stream. |
Test case for a known test vector
Dim data as String
Dim hash as RIPEMD_128
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_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_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_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:
PPC - MacOS 9Carbon - MacOS 9 and MacOS X (PEF)MacOS X PPC - (Mach-O)MacOS X Universal Binary (Mach-O)Win32 - WindowsLinux x86