e-CryptIt Engine Xojo Plugin

SHA_512 Class (console safe)

SHA_512 is a message digest/hash algorithm with a digest/hash size of 512 bits (64 characters).

This algorithm has been tested against official test vectors.

Object
   SHA_512

class SHA_512 implements

IHashAlgorithm

Methods

Final (console safe) Use this function when you are done adding bytes to the SHA_512 class.
Update (console safe) Use this method to add data with MemoryBlock to the SHA_512 stream.
Update (console safe) Use this method to add data with String to the SHA_512 stream.

Test case for a known test vector

Dim data as String
Dim hash as SHA_512
Dim result as String
Dim hexResult as String
Dim i as Integer

data = "abc"

// We do this in ASCII because the well known test vectors come in ASCII
data = ConvertEncoding(data,Encodings.ASCII)

hash = new SHA_512()

hash.Update(data)

result = hash.Final()

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


if hexResult <> Uppercase("ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f") then
    return false
end if


// Lets test another official vector

data = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"

// We do this in ASCII because the well known test vectors come in ASCII
data = ConvertEncoding(data,Encodings.ASCII)

hash = new SHA_512()


hash.Update(data)

result = hash.Final()

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


if hexResult = Uppercase("204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445") then
    return true
else
    return false
end if

Supported Platforms:

  • MacOS X Carbon
  • MacOS X Cocoa 32 bit
  • MacOS X Cocoa 64 bit
  • Windows 32 bit
  • Windows 64 bit
  • Linux 32 bit
  • Linux 64 bit
  • Linux ARM