Using the Sha Crypto Library

I'm attempting to start a simple sketch that calls the cryptosuite Sha library downloaded from code.google.com.

#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

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.

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:

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).

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

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?

Updated / fixed version attached.

Sha.7z (5.21 KB)

Hello. How do you use this to send data to the arduino and decrypt it? All of the examples i saw in the code were outbound from the arduino.

You don't. SHA (hash functions in general) have nothing to do with encryption / decryption. They are used to digitally sign.