user37390: I am manipulating (with pybitcointools) some regular addresses as well as some P2SH and stumbled upon the following:
Case 1:
>>> b58check_to_hex('17rq8m5SW8XoZ9dHEkQyBfc5w2XQnQvznz')
'4b3d51202139ff109f6d10b637081f2de48d4b35'
>>> hex_to_b58check('4b3d51202139ff109f6d10b637081f2de48d4b35')
'17rq8m5SW8XoZ9dHEkQyBfc5w2XQnQvznz'

second command is the inverse mapping of the first one 
Case 2: 
>>> b58check_to_hex('3BRu7EhouApLkW1EZ64T9o9yMuX5Rexz6f')
'6ad55439d8faab476bbc0f89183ce689f8f6985b'
>>> hex_to_b58check('6ad55439d8faab476bbc0f89183ce689f8f6985b')
'1AjtBhDNMGVxfLJoRzPrjAo3DPEMps6xEd'

second command is NOT the inverse mapping of the first one 
This surprises me a lot. Can someone give me some hints as to why this is the case please?
Thank you

user2306: The second case is a P2SH address. You must supply the version number/magic byte for the address, which is 5 for P2SH.
>>> bitcoin.b58check_to_hex('3BRu7EhouApLkW1EZ64T9o9yMuX5Rexz6f')
'6ad55439d8faab476bbc0f89183ce689f8f6985b'
>>> bitcoin.hex_to_b58check('6ad55439d8faab476bbc0f89183ce689f8f6985b', magicbyte=5)
'3BRu7EhouApLkW1EZ64T9o9yMuX5Rexz6f'

To figure out what the magic byte of an address is, use this:
>>> bitcoin.get_version_byte('3BRu7EhouApLkW1EZ64T9o9yMuX5Rexz6f')
5


37390: <p>I am manipulating (with pybitcointools) some regular addresses as well as some P2SH and stumbled upon the following:</p>

<p><strong>Case 1:</strong></p>

<pre><code>&gt;&gt;&gt; b58check_to_hex('17rq8m5SW8XoZ9dHEkQyBfc5w2XQnQvznz')
'4b3d51202139ff109f6d10b637081f2de48d4b35'
&gt;&gt;&gt; hex_to_b58check('4b3d51202139ff109f6d10b637081f2de48d4b35')
'17rq8m5SW8XoZ9dHEkQyBfc5w2XQnQvznz'
</code></pre>

<p>second command is the inverse mapping of the first one </p>

<p><strong>Case 2:</strong> </p>

<pre><code>&gt;&gt;&gt; b58check_to_hex('3BRu7EhouApLkW1EZ64T9o9yMuX5Rexz6f')
'6ad55439d8faab476bbc0f89183ce689f8f6985b'
&gt;&gt;&gt; hex_to_b58check('6ad55439d8faab476bbc0f89183ce689f8f6985b')
'1AjtBhDNMGVxfLJoRzPrjAo3DPEMps6xEd'
</code></pre>

<p>second command is <strong>NOT</strong> the inverse mapping of the first one </p>

<p>This surprises me a lot. Can someone give me some hints as to why this is the case please?</p>

<p>Thank you</p>
 2306: <p>The second case is a P2SH address. You must supply the version number/magic byte for the address, which is 5 for P2SH.</p>

<pre><code>&gt;&gt;&gt; bitcoin.b58check_to_hex('3BRu7EhouApLkW1EZ64T9o9yMuX5Rexz6f')
'6ad55439d8faab476bbc0f89183ce689f8f6985b'
&gt;&gt;&gt; bitcoin.hex_to_b58check('6ad55439d8faab476bbc0f89183ce689f8f6985b', magicbyte=5)
'3BRu7EhouApLkW1EZ64T9o9yMuX5Rexz6f'
</code></pre>

<p>To figure out what the magic byte of an address is, use this:</p>

<pre><code>&gt;&gt;&gt; bitcoin.get_version_byte('3BRu7EhouApLkW1EZ64T9o9yMuX5Rexz6f')
5
</code></pre>
