Initial commit
This commit is contained in:
commit
6c7efdd0f6
59 files changed
+8604
No files matched your search
@@ -0,0 +1,29 @@
|
||||
#include "Destination.h"
|
||||
#include "Utils.h"
|
||||
#include <string.h>
|
||||
|
||||
namespace mesh {
|
||||
|
||||
Destination::Destination(const Identity& identity, const char* name) {
|
||||
uint8_t name_hash[MAX_HASH_SIZE];
|
||||
Utils::sha256(name_hash, MAX_HASH_SIZE, (const uint8_t *)name, strlen(name));
|
||||
|
||||
Utils::sha256(hash, MAX_HASH_SIZE, name_hash, MAX_HASH_SIZE, identity.pub_key, PUB_KEY_SIZE);
|
||||
}
|
||||
|
||||
Destination::Destination(const char* name) {
|
||||
uint8_t name_hash[MAX_HASH_SIZE];
|
||||
Utils::sha256(name_hash, MAX_HASH_SIZE, (const uint8_t *)name, strlen(name));
|
||||
|
||||
Utils::sha256(hash, MAX_HASH_SIZE, name_hash, MAX_HASH_SIZE);
|
||||
}
|
||||
|
||||
Destination::Destination() {
|
||||
memset(hash, 0, MAX_HASH_SIZE);
|
||||
}
|
||||
|
||||
bool Destination::matches(const uint8_t* other_hash) {
|
||||
return memcmp(hash, other_hash, MAX_HASH_SIZE) == 0;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user