| e-CryptIt Engine REALbasic Plugin |
|
HMAC_SHA_256 Class
Implements Keyed-Hashing using SHA_256 for message authentication in compliance with RFC 2104.
This algorithm has been tested against official test vectors.
Object
HMAC_SHA_256
class HMAC_SHA_256 implements
IHashAlgorithm
Constructors
HMAC_SHA_256 | The constructor for the HMAC_SHA_256 takes a key as a parameter. |
Methods
Final | Use this function when you are done adding bytes to the HMAC_SHA_256 class. |
Update | Use this method to add data to the HMAC_SHA_256 stream. |
Test case for a known test vector
Dim key as String
Dim data as String
Dim hmac as HMAC_SHA_256
Dim result as String
Dim hexResult as String
Dim i as Integer
key = "Jefe"
data = "what do ya want for nothing?"
// We do this in ASCII because the well known test vectors come in ASCII
key = ConvertEncoding(key,Encodings.ASCII)
data = ConvertEncoding(data,Encodings.ASCII)
hmac = new HMAC_SHA_256(key)
hmac.Update(data)
result = hmac.Final()
// Convert to HEX
For i = 1 to 32
hexResult = hexResult + Right("0"+Hex(Asc(Mid(result,i,1))),2)
next
if hexResult = "5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843" 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