| e-CryptIt Engine REALbasic Plugin |
|
SHA1 Class
SHA1 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
SHA1
class SHA1 implements
IHashAlgorithm
Methods
Final | Use this function when you are done adding bytes to the SHA1 class. |
Update | Use this method to add data to the SHA1 stream. |
Examples
Dim data as String
Dim hash as SHA1
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 SHA1()
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 <> "A9993E364706816ABA3E25717850C26C9CD0D89D" 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 SHA1()
hash.Update(data)
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 = "84983E441C3BD26EBAAE4AA1F95129E5E54670F1" 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