HASH 05: SHA-384
This example shows how to calculate SHA-384 message digest to provide INTEGRITY to the sending of information. Both data must be sent over the network: MESSAGE + HASH_MESSAGE

Required Materials

1 x Waspmote 1 x Battery

Notes

- The battery has to be connected. - This example can be executed in Waspmote v12 and Waspmote v15

Code

1
/*
2
* ------Waspmote HASH_05 SHA-384 Message Digest--------
3
*
4
* This example shows how to calculate SHA-384 message digest to
5
* provide INTEGRITY to the sending of information. Both data
6
* must be sent over the network: MESSAGE + HASH_MESSAGE
7
*
8
* Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L.
9
* http://www.libelium.com
10
*
11
* This program is free software: you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation, either version 2 of the License, or
14
* (at your option) any later version.
15
*
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
20
*
21
* You should have received a copy of the GNU General Public License
22
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
*
24
* Version: 3.0
25
* Design: David Gascón
26
* Implementation: Alvaro Gonzalez, Yuri Carmona
27
*/
28
29
#include "WaspHash.h"
30
31
32
// Original message
33
char message[] = "Libelium";
34
35
// Variable to store the hash message
36
uint8_t hash_message_sha384[48];
37
38
39
void setup()
40
{
41
USB.ON();
42
USB.println(F("HASH_05 example"));
43
USB.println(F("- SHA-384 algorithm"));
44
USB.println(F("- Message Digest length of 384 bits (48 Bytes)"));
45
USB.println();
46
47
USB.print(F("Original message: "));
48
USB.println(message);
49
}
50
51
void loop()
52
{
53
54
// Calculate hash of original message with MD5 Algorithm
55
HASH.sha( SHA384, hash_message_sha384, (uint8_t*)message, strlen(message)*8);
56
57
// Printing message digest SHA-384
58
HASH.printMessageDigest("SHA-384:", hash_message_sha384, 48);
59
60
delay(5000);
61
}
Copied!

Output

1
H#
2
HASH_05 example
3
- SHA-384 algorithm
4
- Message Digest length of 384 bits (48 Bytes)
5
6
Original message: Libelium
7
SHA-384:"C4AFE67F324E69EA1C6B8133E66B1883B3ACDF57B92CB58DCFBA687A1E64A23B6F0E157D6BD8A6CE1B29BFAE8D8F2154"
Copied!
Last modified 1yr ago