-8-
v7.0
Integrity
Next code shows how to calculate the message digest with
HASH.sha()
. The inputs expected are: the SHA algorithm, the
pointer to the buffer where the output is stored, the input message pointer and the length of the input message.
{
char message[] = “Libelium”;
HASH.sha(SHA1, hash_message, (uint8_t*)message, strlen(message)*8);
}
{
char message[] = “Libelium”;
HASH.sha(SHA384, hash_message, (uint8_t*)message, strlen(message)*8);
}
2.3. Printing Message
Using the hash function
HASH.printMessageDigest()
the message digest is written via USB port.
{
// Write message digest by USB port
HASH.printMessageDigest(“SHA-1:”, hash_message, 20);
HASH.printMessageDigest(“MD5:”, hash_message, 16);
}
Example of use may be found in:
http://www.libelium.com/development/waspmote/examples/hash-01-md5
http://www.libelium.com/development/waspmote/examples/hash-02-sha1