|
Title: different implementations of SHA256 Post by: redPanda on March 17, 2015, 07:10:13 PM Are there different implementations of SHA256 ?
from the bx library: >bx sha256 800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D 8147786c4d15106333bf278d71dadaf1079ef2d2440a4dde37d747ded5403592 from https://en.bitcoin.it/wiki/Wallet_import_format sha256 (800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D) = 8147786c4d15106333bf278d71dadaf1079ef2d2440a4dde37d747ded5403592 and from c++ crypto++: sha256(800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D) = E2E4146A36E9C455CF95A4F259F162C353CD419CC3FD0E69AE36D7D1B6CD2C09 from: http://www.xorbin.com/tools/sha256-hash-calculator sha256(800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D) = e2e4146a36e9c455cf95a4f259f162c353cd419cc3fd0e69ae36d7d1b6cd2c09 Title: Re: different implementations of SHA256 Post by: cr1776 on March 18, 2015, 12:00:38 AM Are there different implementations of SHA256 ? from the bx library: >bx sha256 800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D 8147786c4d15106333bf278d71dadaf1079ef2d2440a4dde37d747ded5403592 from https://en.bitcoin.it/wiki/Wallet_import_format sha256 (800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D) = 8147786c4d15106333bf278d71dadaf1079ef2d2440a4dde37d747ded5403592 and from c++ crypto++: sha256(800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D) = E2E4146A36E9C455CF95A4F259F162C353CD419CC3FD0E69AE36D7D1B6CD2C09 from: http://www.xorbin.com/tools/sha256-hash-calculator sha256(800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D) = e2e4146a36e9c455cf95a4f259f162c353cd419cc3fd0e69ae36d7d1b6cd2c09 The difference is in hashing the string (an ASCII representation of a hex number) instead of the actual hex number itself. The wiki hashes the number, the calculator is hashing the string. Title: Re: different implementations of SHA256 Post by: redPanda on March 18, 2015, 02:34:23 PM I finally got the right output:
instead of doing: Code: // WRONG Code: // OK Title: Re: different implementations of SHA256 Post by: cr1776 on March 18, 2015, 03:10:36 PM I finally got the right output: instead of doing: Code: // WRONG Code: // OK Exactly! ;-) It can be tricky. |