File tree 1 file changed +4
-14
lines changed
1 file changed +4
-14
lines changed Original file line number Diff line number Diff line change 10
10
11
11
#include " bpid.h"
12
12
#include " ../sha256/SHA256.h"
13
+ #include " ../hex/hex.h"
13
14
14
15
namespace arduino { namespace bpid {
15
16
16
- static String hexEncode (uint8_t * in, uint32_t size) {
17
- String out;
18
- out.reserve ((size * 2 ) + 1 );
19
-
20
- char *ptr = out.begin ();
21
- for (uint32_t i = 0 ; i < size; i++) {
22
- ptr += sprintf (ptr, " %02X" , in[i]);
23
- }
24
- return String (out.c_str ());
25
- }
26
-
27
17
bool get (uint8_t * in, uint32_t size) {
28
18
if (size < BOARD_PROVISIONING_ID_SIZE) {
29
19
return false ;
@@ -46,11 +36,11 @@ namespace arduino { namespace bpid {
46
36
String get () {
47
37
uint8_t data[BOARD_PROVISIONING_ID_SIZE];
48
38
if (!get (data, sizeof (data))) {
49
- return String (" FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF " );
39
+ return String (" " );
50
40
}
51
41
uint8_t out[SHA256::HASH_SIZE];
52
- arduino::sha256::oneshot (data, sizeof (data), out, sizeof (data) );
53
- return hexEncode (out, sizeof (out));
42
+ arduino::sha256::oneshot (data, sizeof (data), out);
43
+ return arduino::hex::encode (out, sizeof (out));
54
44
}
55
45
56
46
}} // arduino::bpid
You can’t perform that action at this time.
0 commit comments