e-CryptIt Engine Xojo Plugin |
|
SHA_256 Class (console safe)
SHA_256 is a message digest/hash algorithm with a digest/hash size of 256 bits (32 characters).
This algorithm has been tested against official test vectors.
Object
SHA_256
class SHA_256 implements
IHashAlgorithm
Methods
Final | Use this function when you are done adding bytes to the SHA_256 class. |
shared Hash | Convenience shared function to hash small data with just one line of code without creating instance of the class. |
Update | Use this method to add data with MemoryBlock to the SHA_256 stream. |
Update | Use this method to add data with String to the SHA_256 stream. |
Constants
Version = 16.12 | |
Test case for a known test vector
Dim data as String
Dim hash as SHA_256
Dim result as String
Dim hexResult as String
Dim i as Integer
data = "abc"
data = ConvertEncoding(data,Encodings.ASCII)
hash = new SHA_256()
hash.Update(data)
result = hash.Final()
For i = 1 to 32
hexResult = hexResult + Right("0"+Hex(Asc(Mid(result,i,1))),2)
next
if hexResult <> "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" then
return false
end if
data = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
data = ConvertEncoding(data,Encodings.ASCII)
hash = new SHA_256()
hash.Update(data)
result = hash.Final()
hexResult = ""
For i = 1 to 32
hexResult = hexResult + Right("0"+Hex(Asc(Mid(result,i,1))),2)
next
if hexResult = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1" then
return true
else
return false
end if
Supported Platforms:
macOS Intel 64 bitmacOS Apple SiliconWindows 32 bitWindows 64 bitWindows ARM 64 bitLinux 32 bitLinux 64 bitLinux ARM 32 bitLinux ARM 64 bitiOS