Skip to content

Commit c005cd4

Browse files
committed
BPId remove static hexEncode function
1 parent 83ff146 commit c005cd4

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/bpid/bpid.cpp

+4-14
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,10 @@
1010

1111
#include "bpid.h"
1212
#include "../sha256/SHA256.h"
13+
#include "../hex/hex.h"
1314

1415
namespace arduino { namespace bpid {
1516

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-
2717
bool get(uint8_t* in, uint32_t size) {
2818
if (size < BOARD_PROVISIONING_ID_SIZE) {
2919
return false;
@@ -46,11 +36,11 @@ namespace arduino { namespace bpid {
4636
String get() {
4737
uint8_t data[BOARD_PROVISIONING_ID_SIZE];
4838
if (!get(data, sizeof(data))) {
49-
return String("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
39+
return String("");
5040
}
5141
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));
5444
}
5545

5646
}} // arduino::bpid

0 commit comments

Comments
 (0)