Page 1 of 1

SHA256 encryption example?

Posted: Tue Jan 07, 2020 5:03 am
by zliudr
I'm searching for example code for SHA256 but found some highly "cryptic" unit test code for it, nothing useful. Any direction to a simple encryption code is appreciated!

Re: SHA256 encryption example?

Posted: Tue Jan 07, 2020 8:35 am
by ESP_Sprite
Erm, you are aware that SHA256 is an hashing algorithm, not an encryption algorithm? If you can find a way to 'decrypt' SHA, there's probably a dozen nobel prizes waiting for you :P Aside from that, what examples specifically are you looking for? There's the 'raw' hardware interfaces, but you may be better off using the esp-idf mbedtls or libsodium components; it should be easy to find examples for that.

Re: SHA256 encryption example?

Posted: Wed Jan 08, 2020 8:24 pm
by zliudr
Since posting this thread I've come across both terms mbedtls and libsodium. I've not found examples included in esp-idf for mbedtls hmac sha256 though. It's unfortunate. Any link to an actual example in esp-idf? I had to use an online tutorial for esp-arduino and piece together my understanding by reading sha256.h and md.h. It's not supposed to be like this.

https://techtutorialsx.com/2018/01/25/e ... mechanism/

I would like to see a standard example from the source, not someone else who may or may not know all the tricks one has to do to make the library work correctly.

Re: SHA256 encryption example?

Posted: Wed Jan 08, 2020 11:03 pm
by chegewara
zliudr wrote: I would like to see a standard example from the source, not someone else who may or may not know all the tricks one has to do to make the library work correctly.
If you want standard examples from source then you are looking in wrong place. mbedtls is 3rd party library, so you should look at mbedtls.
https://tls.mbed.org/

Re: SHA256 encryption example?

Posted: Thu Jan 09, 2020 3:18 am
by zliudr
chegewara wrote:
Wed Jan 08, 2020 11:03 pm
zliudr wrote: I would like to see a standard example from the source, not someone else who may or may not know all the tricks one has to do to make the library work correctly.
If you want standard examples from source then you are looking in wrong place. mbedtls is 3rd party library, so you should look at mbedtls.
https://tls.mbed.org/
Bookmarked. Thank you!