espressif / esp-wolfssl

WolfSSL port for ESP-IDF & ESP8266_RTOS_SDK
40 stars 13 forks source link

how do I use this library to create a SHA1 Hasher? #18

Closed zhy2020 closed 1 year ago

zhy2020 commented 1 year ago

Hi, how do I use this library to implement the following python code?

from cryptography.hazmat.primitives import hashes vin = bytes("5YJ3E1EA1KF000000", "UTF8")

Create A SHA1 Hasher

digest = hashes.Hash(hashes.SHA1())

Put VIN Into The Hasher

digest.update(vin)

Set vinSHA To The Hex String Of The VIN Hash

vinSHA = digest.finalize().hex()

Get The First 16 Characters

middleSection = vinSHA[0:16] print(middleSection) # a6bab0d54ffaecf1

gojimmypi commented 1 year ago

Hi @zhy2020 there's a wolfssl test that includes SHA1 hashes. See the int sha_test(void) in test.c.

Let me know if that helps. If you encounter any problems, you can open an issue there and I can help you further.

zhy2020 commented 1 year ago

Hi @zhy2020 there's a wolfssl test that includes SHA1 hashes. See the int sha_test(void) in test.c.

Let me know if that helps. If you encounter any problems, you can open an issue there and I can help you further.

thanks.