Pages: [1]   Go Down
Author Topic: Using the Sha Crypto Library  (Read 2195 times)
0 Members and 1 Guest are viewing this topic.
Near San Diego
Offline Offline
Jr. Member
**
Karma: 1
Posts: 69
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm attempting to start a simple sketch that calls the cryptosuite Sha library downloaded from code.google.com.
Code:
#include "sha1.h"
void setup() {
  // put your setup code here, to run once:
 uint8_t *hash;
  Sha1.init();
  Sha1.print("This is a message to hash");
  hash = Sha1.result();
}
void loop() {
  // put your main code here, to run repeatedly:
 
}

I get this error when compiling:
In file included from BareMinimum.cpp:2:
C:\Users\James Brown\Documents\Arduino\arduino-1.0.1\libraries\Sha/sha1.h:26: error: conflicting return type specified for 'virtual void Sha1Class::write(uint8_t)'
C:\Users\James Brown\Documents\Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'

I am clueless as what to do. 

Thanks......... Jim

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 652
Posts: 50869
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I am clueless as what to do.
Perhaps search for this error message that has been posted more than once.

Or, actually read the messages.
Quote
error: conflicting return type specified for 'virtual void Sha1Class::write(uint8_t)'
It doesn't seem too hard to understand this part. You should be able to determine that the return type for this function is void. It conflicts with something that says the return type should be something else. What does it conflict with, and what should the return type be? Well, that is answered in the next message:
Quote
error:   overriding 'virtual size_t Print::write(uint8_t)'

The Sha1Class class derives from Print, which says that the write() method returns a size_t value. So, you need to edit the Sha1Class header file, and change the return type of the write() method to size_t, instead of void.

Then, you need to edit the Sha1Class source file, and make the same change, AND make the class actually return a value (typically 1).
Logged

Near San Diego
Offline Offline
Jr. Member
**
Karma: 1
Posts: 69
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the input.  I'll ignore the snark and work it out.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am currently having the exact same problem and it is veeeery annoying.  I have a hit a wall and do not know what to do.  Changing it to a return type size_t did absolutely nothing.   can someone please lend a helping hand?
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13074
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Updated / fixed version attached.

* Sha.7z (5.21 KB - downloaded 7 times.)
Logged

Pages: [1]   Go Up
Jump to: