Halsh / smallsha1

Automatically exported from code.google.com/p/smallsha1
0 stars 0 forks source link

smallsha1 on Arduino #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I'm attempting to re-write the excellent smallsha1 for Arduino. The big issue 
is that the Arduino environment has 16-bit ints, instead of the 32 bits 
expected here. My naive strategy was to replace ints with longs.

Weirdly, calc(..) now works for arrays of three characters, but not for other 
lengths:

plain text: "abc"
result: a9993e364706816aba3e25717850c26c9cd0d89d
expected: a9993e364706816aba3e25717850c26c9cd0d89d

plain text: ""
result: 92b404e556588ced6c1acd4ebf053f6809f73a93
expected: da39a3ee5e6b4b0d3255bfef95601890afd80709

plain text: "hello"
result: 0c2a6006740560e244bea4096941fe2efb556fc0
expected: aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d

Any thoughts? I'm attaching the hacked version of the source.

Bruno

Original issue reported on code.google.com by bbel...@me.com on 6 Jun 2014 at 5:17

Attachments:

GoogleCodeExporter commented 8 years ago
Edit: it works for arrays of characters whose length - including the 
terminating '\0' character - is a multiple of four.

Original comment by bbel...@me.com on 6 Jun 2014 at 10:35

GoogleCodeExporter commented 8 years ago
SOLVED: The terminating constant must be explicitly defined as an unsigned long.

Source code attached.

Original comment by bbel...@me.com on 7 Jun 2014 at 9:25

Attachments: