* ------Waspmote HASH_02 SHA-1 Message Digest--------
* This example shows how to calculate SHA-1 message digest to
* provide INTEGRITY to the sending of information. Both data
* must be sent over the network: MESSAGE + HASH_MESSAGE
* Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* Implementation: Alvaro Gonzalez, Yuri Carmona
char message[] = "Libelium";
// Variable to store the hash message
uint8_t hash_message_sha1[20];
USB.println(F("HASH_02 example"));
USB.println(F("- SHA-1 algorithm"));
USB.println(F("- Message Digest length of 160 bits (20 Bytes)"));
USB.print(F("Original message: "));
// Calculate hash of original message with SHA-1 Algorithm
HASH.sha( SHA1, hash_message_sha1, (uint8_t*)message, strlen(message)*8);
// Printing message digest SHA-1
HASH.printMessageDigest("SHA-1:", hash_message_sha1 , 20);