<p>As you can see in the code, the word is hashed using SHA256 to get the private key. Because private keys in Bitcoin have 32 bytes, you can't just use any word directly as a private key, and one way of converting it into a private key is to run it through a hash function that outputs 32 bytes, such as SHA256. (It should be obvious that creating a private key from a single English word isn't secure.)</p>
<p><a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki" rel="nofollow noreferrer">BIP39</a> is the most commonly used standard for 12-word mnemonics. It doesn't use SHA256 but HMAC-SHA512, and usually isn't used for creating just one private key but an entire chain of private keys using <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" rel="nofollow noreferrer">BIP32</a>.</p>

CC BY-SA 4.0
2024-03-01T19:09:13.397Z
2024-03-01T19:09:13.397Z
Vojtěch Strnad
<p>I have the following code</p>
<pre><code>import hashlib
import binascii

def word_to_private_key(word):
    sha256_hash = hashlib.sha256(word.encode()).digest()
    private_key = binascii.hexlify(sha256_hash).decode()
    return private_key

word = &quot;hello&quot;
private_key = word_to_private_key(word)
print(&quot;Bitcoin Private Key:&quot;, private_key)
</code></pre>
<p>Here hello is converted into bitcoin private key. Surprisingly I see some transactions with that private key.</p>
<p>For any string of the word variable there is one btc private key</p>
<p>My question is - what is the relation between string and bitcoin private key?
Could you make me understand in simple way?</p>
<p>Also why people talk about 12 word seed? Here one word is converted into private key.</p>

<private-key><hash><python><cryptography><mnemonic-seed>
What is one word seed word exactly?
Asif Iqbal
# What is one word seed word exactly?

(Asked by: username_0 on 2024-03-01)

I have the following code

```
import hashlib
import binascii

def word_to_private_key(word):
    sha256_hash = hashlib.sha256(word.encode()).digest()
    private_key = binascii.hexlify(sha256_hash).decode()
    return private_key

word = "hello"
private_key = word_to_private_key(word)
print("Bitcoin Private Key:", private_key)

```

Here hello is converted into bitcoin private key. Surprisingly I see some transactions with that private key.

For any string of the word variable there is one btc private key

My question is - what is the relation between string and bitcoin private key?
Could you make me understand in simple way?

Also why people talk about 12 word seed? Here one word is converted into private key.

**Tags:** private-key, hash, python, cryptography, mnemonic-seed


---

## 1 answers

### Answer by username_1 on 2024-03-01. Score: 1

As you can see in the code, the word is hashed using SHA256 to get the private key. Because private keys in Bitcoin have 32 bytes, you can't just use any word directly as a private key, and one way of converting it into a private key is to run it through a hash function that outputs 32 bytes, such as SHA256. (It should be obvious that creating a private key from a single English word isn't secure.)

[BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) is the most commonly used standard for 12-word mnemonics. It doesn't use SHA256 but HMAC-SHA512, and usually isn't used for creating just one private key but an entire chain of private keys using [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki).


---

