user35892: On the Bitcoin wiki it has steps to convert a private key to WIF. So I tried following these steps in attempt to get the same result.
So I took the private key.
0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D

I put 80 on the front.
800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D

And then I performed SHA-256 on it using this.
e2e4146a36e9c455cf95a4f259f162c353cd419cc3fd0e69ae36d7d1b6cd2c09

And that is where I run into a problem. On the wiki page it says the result of SHA-256 should be...
8147786C4D15106333BF278D71DADAF1079EF2D2440A4DDE37D747DED5403592

And that does not match my SHA-256 result.
Not sure what I am doing wrong.

user3041: The value

e2e4146a36e9c455cf95a4f259f162c353cd419cc3fd0e69ae36d7d1b6cd2c09

corresponds to the SHA-256 hash of the string: 

800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D

In order to obtain the desired result, the key has to be interpreted as a hexadecimal value. For instance, using this website to compute the hash, we obtain the same result than in the wiki:

8147786c4d15106333bf278d71dadaf1079ef2d2440a4dde37d747ded5403592


user54511: you need to use bytes.fromhex() function.
here is a related example (python3)
import hashlib
import ecdsa
import base58


def generate_private_and_public_keys(secret):
    #hash digest
    digest = hashlib.sha256(secret.encode()).hexdigest()

    #signing and verification keys
    signing_key = ecdsa.SigningKey.from_string(bytes.fromhex(digest), curve=ecdsa.SECP256k1)

    verifying_key = signing_key.verifying_key
    public_key = '04' + verifying_key.to_string().hex()

    return signing_key.to_string().hex(), public_key;


def get_wif_public_key(public_key):
    ripemd160 = hashlib.new('ripemd160')
    ripemd160.update(hashlib.sha256(bytes.fromhex(public_key)).digest())
    mm = '00' + ripemd160.digest().hex()

    checksum = hashlib.sha256((hashlib.sha256(bytes.fromhex(mm)).digest())).digest()[0:4]

    binary_addr = mm + checksum.hex()
    return base58.b58encode(bytes.fromhex(binary_addr))


private_key, public_key = generate_private_and_public_keys('erfjer;ljfecfv kfk  gf 74764 dlr;f;cmiofmsr')
print ('Private_key: {}'.format(private_key))
print ('Public key: {}'.format(public_key))

wif = get_wif_public_key(public_key)
print ('Bitcoin address: {}'.format(wif))


user10377: Here is how to use the bitcoin-explorer command line to generate an uncompressed WIF private key on a UNIX box:

% echo 0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D | bx base58check-encode -v 128

5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ

The following provides feedback for going the opposite direction:

% echo 5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ | bx base58check-decode 

wrapper 
{ 
  checksum 2371582544    
  payload  0c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d   
  version  128 
}

To create a compressed WIF private key just suffix the private hex encoded key with 01:

% echo 0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D01 | bx base58check-encode -v 128

KwdMAjGmerYanjeui5SHS7JkmpZvVipYvB2LJGU1ZxJwYvP98617
Alternatively the following set of piped commands perform the same functionality:

% echo 0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D | sed 's/$/01/' | bx wrap-encode -v 128 | bx base58-encode

0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D01
800c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d01a62019d2
KwdMAjGmerYanjeui5SHS7JkmpZvVipYvB2LJGU1ZxJwYvP98617
The following double checks the compressed WIF key encoding:

% echo KwdMAjGmerYanjeui5SHS7JkmpZvVipYvB2LJGU1ZxJwYvP98617 | bx base58check-decode

wrapper 
{
  checksum 3524862118
  payload 0c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d01
  version 128 
}


user35889: You're performing a SHA256 on an ASCII string, not on the actual number. That ASCII string is actually the hexadecimal representation of the actual number.
This is a little code snippet that uses a hex2bin function to turn the hexadecimal representation (from your question) into an actual number before performing the sha256 on it.

35892: <p>On the Bitcoin wiki it has <a href="https://en.bitcoin.it/wiki/Wallet_import_format" rel="nofollow">steps</a> to convert a private key to WIF. So I tried following these steps in attempt to get the same result.</p>

<p>So I took the private key.</p>

<pre><code>0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D
</code></pre>

<p>I put 80 on the front.</p>

<pre><code>800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D
</code></pre>

<p>And then I performed SHA-256 on it using <a href="http://www.xorbin.com/tools/sha256-hash-calculator" rel="nofollow">this</a>.</p>

<pre><code>e2e4146a36e9c455cf95a4f259f162c353cd419cc3fd0e69ae36d7d1b6cd2c09
</code></pre>

<p>And that is where I run into a problem. On the wiki page it says the result of SHA-256 should be...</p>

<pre><code>8147786C4D15106333BF278D71DADAF1079EF2D2440A4DDE37D747DED5403592
</code></pre>

<p>And that does not match my SHA-256 result.</p>

<p>Not sure what I am doing wrong.</p>
 3041: <p>The value</p>

<blockquote>
  <p>e2e4146a36e9c455cf95a4f259f162c353cd419cc3fd0e69ae36d7d1b6cd2c09</p>
</blockquote>

<p>corresponds to the SHA-256 hash of the <strong>string</strong>: </p>

<blockquote>
  <p>800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D</p>
</blockquote>

<p>In order to obtain the desired result, the key has to be interpreted as a <strong>hexadecimal value</strong>. For instance, using <a href="http://www.fileformat.info/tool/hash.htm?hex=800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D" rel="nofollow">this website</a> to compute the hash, we obtain the same result than in the wiki:</p>

<blockquote>
  <p>8147786c4d15106333bf278d71dadaf1079ef2d2440a4dde37d747ded5403592</p>
</blockquote>
 54511: <p>you need to use bytes.fromhex() function.</p>

<p>here is a related example (python3)</p>

<pre><code>import hashlib
import ecdsa
import base58


def generate_private_and_public_keys(secret):
    #hash digest
    digest = hashlib.sha256(secret.encode()).hexdigest()

    #signing and verification keys
    signing_key = ecdsa.SigningKey.from_string(bytes.fromhex(digest), curve=ecdsa.SECP256k1)

    verifying_key = signing_key.verifying_key
    public_key = '04' + verifying_key.to_string().hex()

    return signing_key.to_string().hex(), public_key;


def get_wif_public_key(public_key):
    ripemd160 = hashlib.new('ripemd160')
    ripemd160.update(hashlib.sha256(bytes.fromhex(public_key)).digest())
    mm = '00' + ripemd160.digest().hex()

    checksum = hashlib.sha256((hashlib.sha256(bytes.fromhex(mm)).digest())).digest()[0:4]

    binary_addr = mm + checksum.hex()
    return base58.b58encode(bytes.fromhex(binary_addr))


private_key, public_key = generate_private_and_public_keys('erfjer;ljfecfv kfk  gf 74764 dlr;f;cmiofmsr')
print ('Private_key: {}'.format(private_key))
print ('Public key: {}'.format(public_key))

wif = get_wif_public_key(public_key)
print ('Bitcoin address: {}'.format(wif))
</code></pre>
 10377: <p>Here is how to use the <a href="https://github.com/libbitcoin/libbitcoin-explorer" rel="nofollow">bitcoin-explorer</a> command line to generate an uncompressed WIF private key on a UNIX box:</p>

<blockquote>
  <p>% echo 0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D | bx base58check-encode -v 128</p>
</blockquote>

<pre><code>5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ
</code></pre>

<p>The following provides feedback for going the opposite direction:</p>

<blockquote>
  <p>% echo 5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ | bx base58check-decode </p>
</blockquote>

<pre><code>wrapper 
{ 
  checksum 2371582544    
  payload  0c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d   
  version  128 
}
</code></pre>

<p>To create a compressed WIF private key just suffix the private hex encoded key with <strong>01</strong>:</p>

<blockquote>
  <p>% echo 0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D<strong>01</strong> | bx base58check-encode -v 128</p>
</blockquote>

<p><code>KwdMAjGmerYanjeui5SHS7JkmpZvVipYvB2LJGU1ZxJwYvP98617</code></p>

<p>Alternatively the following set of piped commands perform the same functionality:</p>

<blockquote>
  <p>% echo 0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D | sed 's/$/01/' | bx wrap-encode -v 128 | bx base58-encode</p>
</blockquote>

<p><code>0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D01</code>
<code>800c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d01a62019d2</code>
<code>KwdMAjGmerYanjeui5SHS7JkmpZvVipYvB2LJGU1ZxJwYvP98617</code></p>

<p>The following double checks the compressed WIF key encoding:</p>

<blockquote>
  <p>% echo KwdMAjGmerYanjeui5SHS7JkmpZvVipYvB2LJGU1ZxJwYvP98617 | bx base58check-decode</p>
</blockquote>

<pre><code>wrapper 
{
  checksum 3524862118
  payload 0c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d01
  version 128 
}
</code></pre>
 35889: <p>You're performing a SHA256 on an ASCII string, not on the actual number. That ASCII string is actually the hexadecimal representation of the actual number.</p>

<p><a href="https://ideone.com/DDM7vX" rel="nofollow">This is a little code snippet</a> that uses a hex2bin function to turn the hexadecimal representation (from your question) into an actual number before performing the sha256 on it.</p>
