<p>No, the correct result should be <code>c555eab45d08845ae9f10d452a99bfcb06f74a50b988fe7e48dd323789b88ee3</code>.</p>
<p>I think this interpreter is just wrong. Looking at the source code, it has other deviations from the protocol (e.g. <code>OP_MUL</code>, which doesn't exist).</p>

CC BY-SA 4.0
2022-10-06T22:28:39.453Z
Thanks! I'll avoid that one and find something else to double-check my code.
leslie
CC BY-SA 4.0
2022-10-06T22:20:02.070Z
2022-10-06T22:20:02.070Z
Pieter Wuille
<p>I'm building my own Bitcoin script interpreter for learning purposes.
I've compared my results with <a href="https://siminchen.github.io/bitcoinIDE/build/editor.html" rel="nofollow noreferrer">https://siminchen.github.io/bitcoinIDE/build/editor.html</a></p>
<p>And the script <code>OP_16 OP_SHA256</code> which results from:</p>
<pre><code>0x4A44DC15364204A80FE80E9039455CC1608281820FE2B24F1E5233ADE6AF1DD5
</code></pre>
<p>That is the hash of the string representation of '10' (16 in hex)</p>
<p>Instead of the hash of the bits
(which is: <code>c555eab45d08845ae9f10d452a99bfcb06f74a50b988fe7e48dd323789b88ee3</code>)</p>
<p>Does the bitcoin script interpreter hash the string representation of any hex value, instead of hashing the raw number?</p>
<p>edit: Is it a normal behavior, to prevent things like <code>SHA256(1) == SHA256(01)</code>?</p>
<p>Thank you all for your answers.</p>

<script><hash><p2sh>
OP_SHA256 - Hashing the string representation
leslie
# OP_SHA256 - Hashing the string representation

(Asked by: username_0 on 2022-10-06)

I'm building my own Bitcoin script interpreter for learning purposes.
I've compared my results with <https://siminchen.github.io/bitcoinIDE/build/editor.html>

And the script `OP_16 OP_SHA256` which results from:

```
0x4A44DC15364204A80FE80E9039455CC1608281820FE2B24F1E5233ADE6AF1DD5

```

That is the hash of the string representation of '10' (16 in hex)

Instead of the hash of the bits
(which is: `c555eab45d08845ae9f10d452a99bfcb06f74a50b988fe7e48dd323789b88ee3`)

Does the bitcoin script interpreter hash the string representation of any hex value, instead of hashing the raw number?

edit: Is it a normal behavior, to prevent things like `SHA256(1) == SHA256(01)`?

Thank you all for your answers.

**Tags:** script, hash, p2sh


---

## 1 answers

### Answer by username_1 on 2022-10-06. Score: 1 | Accepted answer

No, the correct result should be `c555eab45d08845ae9f10d452a99bfcb06f74a50b988fe7e48dd323789b88ee3`.

I think this interpreter is just wrong. Looking at the source code, it has other deviations from the protocol (e.g. `OP_MUL`, which doesn't exist).

> **Comments:**
> **username_0**: Thanks! I'll avoid that one and find something else to double-check my code.  

---

