Skip to content

Commit

Permalink
Fixed generic SHA1 name causing conflicts with other libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanclief committed Jun 29, 2024
1 parent d7a68ae commit b343bea
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions examples/SHA1/SHA1.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
ArduinoBearSSL SHA1
ArduinoBearSSL BearSHA1
This sketch demonstrates how to create a SHA1 hash and HMAC
This sketch demonstrates how to create a BearSHA1 hash and HMAC
for an input string.
This example code is in the public domain.
Expand Down Expand Up @@ -30,35 +30,35 @@ void loop() {
}

void printSHA1(const char* str) {
Serial.print("SHA1 of '");
Serial.print("BearSHA1 of '");
Serial.print(str);
Serial.print("' is 0x");

SHA1.beginHash();
SHA1.print(str);
SHA1.endHash();
BearSHA1.beginHash();
BearSHA1.print(str);
BearSHA1.endHash();

printResult();
}

void printHMACSHA1(const char* secret, const char* str) {
Serial.print("HMAC-SHA1 of '");
Serial.print("HMAC-BearSHA1 of '");
Serial.print(str);
Serial.print("' with secret '");
Serial.print(secret);
Serial.print("' is 0x");

SHA1.beginHmac(secret);
SHA1.print(str);
SHA1.endHmac();
BearSHA1.beginHmac(secret);
BearSHA1.print(str);
BearSHA1.endHmac();

printResult();
}

void printResult()
{
while (SHA1.available()) {
byte b = SHA1.read();
while (BearSHA1.available()) {
byte b = BearSHA1.read();

if (b < 16) {
Serial.print("0");
Expand Down
2 changes: 1 addition & 1 deletion src/SHA1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ int SHA1Class::end(uint8_t *digest)
return 1;
}

SHA1Class SHA1;
SHA1Class BearSHA1;
2 changes: 1 addition & 1 deletion src/SHA1.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ class SHA1Class: public SHAClass {
br_sha1_context _ctx;
};

extern SHA1Class SHA1;
extern SHA1Class BearSHA1;

#endif

0 comments on commit b343bea

Please sign in to comment.