Research Article
Research on Grain Food Blockchain Traceability Information Management Model Based on Master-Slave Multichain
| Input: hash value of the previous block prehash, difficulty n; | | Output: random number nonce; | (1) | def hash (prehash, nonce); | (2) | str = f′{prehash}{nonce}′.encode() | (3) | return hashlib.sha256 (str).hexdigest ()//Generate SHA256 Summary | (4) | def proof (prehash.n): | (5) | nonce = 0 | (6) | while hash (prehash.nonce) [:n] ! = str (0).zfill (n) | (7) | nonce+ = 1 | (8) | return nonce |
|