These are chat archives for esp8266/Arduino

20th
May 2015
Markus
@Links2004
May 20 2015 17:00
sha1 is working :) Links2004/Arduino@79b374e
Ivan Grokhotkov
@igrr
May 20 2015 17:01
why did you add SHA1Update source?
we have this function in the ROM
same for SHA1Transform and SHA1Init
you just need to declare the function prototypes and then the linker will bind the calls to the functions in the ROM
Markus
@Links2004
May 20 2015 17:04
k then i misunderstood something will change it
Ivan Grokhotkov
@igrr
May 20 2015 17:04
just leave sha1.h and remove sha1.c
Also i would suggest to stick to the naming convention and have the main include file of the library in uppercase
libraries/Hash/src/hash.h -> libraries/Hash/src/Hash.h
people on Linux will get one less problem
Markus
@Links2004
May 20 2015 17:06
k
Ivan Grokhotkov
@igrr
May 20 2015 17:06
thanks otherwise :)
Markus
@Links2004
May 20 2015 17:10
cant commit the renaming on windows... git ignore the change.
need to start my linux machine
Ivan Grokhotkov
@igrr
May 20 2015 17:11
you can make that two commits
hash.h -> Hash1.h -> Hash.h
messy but should do the job
Markus
@Links2004
May 20 2015 17:11
k will try
may i can afterwards put them in one commit
Markus
@Links2004
May 20 2015 17:20
k that i missed
done
Ivan Grokhotkov
@igrr
May 20 2015 17:21
also since you have this overload void sha1(const uint8_t * data, uint32_t size, uint8_t hash[20]); the cast should not be necessary here: https://github.com/Links2004/Arduino/blob/8893631d255e9df3e4e622e1de6b8fefd43376df/hardware/esp8266com/esp8266/libraries/Hash/examples/sha1.ino#L15
sha1(test, sizeof(test)-1, hash); should work
Markus
@Links2004
May 20 2015 17:22
yes it will, shut have save my last test code before copy it to examples ....
Ivan Grokhotkov
@igrr
May 20 2015 17:23
one more thing — maybe add the function which will just output the string?
that's what most people will need
String sha1str(String)
or String sha1str(const uint8_t*)
smth like that
Markus
@Links2004
May 20 2015 17:24
will add
String sha1(const uint8_t*, uint32_t size);
String sha1(String);
is returning a string even possible its a class ? it will lose its reference when i create it inside the function.
Ivan Grokhotkov
@igrr
May 20 2015 17:27
Strings can be copied so that's okay
in the worst case another instance will be created and returned
Markus
@Links2004
May 20 2015 17:28
k
Ivan Grokhotkov
@igrr
May 20 2015 17:28
in the best case the compiler will do r-value optimization and return the existing instance
Markus
@Links2004
May 20 2015 17:42

end up with this:

void sha1(uint8_t * data, uint32_t size, uint8_t hash[20]);
void sha1(char * data, uint32_t size, uint8_t hash[20]);
void sha1(const uint8_t * data, uint32_t size, uint8_t hash[20]);
void sha1(const char * data, uint32_t size, uint8_t hash[20]);
void sha1(String data , uint8_t hash[20]);

String sha1(uint8_t* data, uint32_t size);
String sha1(char* data, uint32_t size);
String sha1(uint8_t* data, uint32_t size);
String sha1(const char* data, uint32_t size);
String sha1(String data);

;)

Ivan Grokhotkov
@igrr
May 20 2015 17:43
covered all the bases :)