This module implements a hash algorithm for binary data. The exact list of available algorithms depends on the board. Among the algorithms that can be implemented:
The latest modern hash algorithm of the SHA256-SHA2 series. It is suitable for password security purposes. Unless it has a specific code size limit, it is recommended to include it in the MicroPython kernel, and it is recommended that any development board provides this feature.
There is hardware acceleration in K210, not software calculation
a = bytes(*65) b = hashlib.sha256(a) c = b.digest() print(c)
Create a SHA256 hash object and selectively feed data into it.
Enter more binary data into the hash.
Returns the hash of all data passed through the hash as a bytes object. After calling this method, no more data can be fed into the hash.
micropython, using this function will complete the final calculation, instead of simply displaying the result, it can only be called once. If you want to use this value multiple times, please save it to a variable
c = b.digest() print(c)
Multiple calls will find that the return value is different
c = b.digest() d = b.digest() print(c == d) # False
This method is not implemented. Use
ubinascii.hexlify(hash.digest()) to get a similar effect.