<p>You should consider using this (or a similar) python library to import your keys, as straight conversion from hex to base58 can have a few gotchas: </p>

<p><a href="https://github.com/vbuterin/pybitcointools" rel="nofollow">https://github.com/vbuterin/pybitcointools</a></p>

<p>Check the examples in the README and you should be on your way to making your script.</p>

CC BY-SA 3.0
2015-12-01T00:14:05.043Z
2015-12-01T00:14:05.043Z
Josh Cincinnati
<p>You can use these little scripts in command line, so you don't have to program a single line (also run in Windows if you have Python), or easily modify them if you want:</p>
<p><strong><a href="https://github.com/circulosmeos/bitcoin-in-tiny-pieces" rel="nofollow noreferrer">https://github.com/circulosmeos/bitcoin-in-tiny-pieces</a></strong></p>
<p>For your private key example:</p>
<pre><code>$ ./bitcoin-wif-from-private-key.py 00010966776006953D5567439E5E39F86A0D273BEED61967F6

privkey = 8000010966776006953D5567439E5E39F86A0D273BEED61967F6

For uncompressed public key:
checksum =      02d037e84dee212e14b823a8c9ac01409f6c1504e558d86116a4302d4d68bbdf
key + checksum =        8000010966776006953D5567439E5E39F86A0D273BEED61967F6 02d037e8
bitcoin address =       Sea2qLkneYfbTv29SLY8QvhkAZDxwgDfMuWprqj4b

For compressed public key:
checksum =      021538258480bbb46a846ef24bb2927d24f7c90bf354d76d6da3bd52c47e633d
key + checksum =        8000010966776006953D5567439E5E39F86A0D273BEED61967F601 02153825
bitcoin address =       2xCpo6NCGUimM7o24EqEPic2qXBEDvL6tKGne3Avisv
</code></pre>
<p>If you modifiy the script setting this variable to False, only WIF addresses are printed:</p>
<pre><code>VERBOSE = False
</code></pre>
<p>(Once you have programmed the desired output) you can make a batch file (.sh in linux, .bat in Windows) with a command line per private key (an editor like <a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwjY_rmgyJvqAhUZA2MBHWY_BrIQjBAwAXoECAYQAg&amp;url=https%3A%2F%2Fwww.sublimetext.com%2F3&amp;usg=AOvVaw0BtVmjapIa9yP4qOnqEhSR" rel="nofollow noreferrer">Sublime Text</a> for example can edit and paste multiple lines at once, so it's easy) each appending to the a file, and the run this batch file:</p>
<pre><code>./bitcoin-wif-from-private-key.py 1stkey &gt;&gt; mytextfile.txt
./bitcoin-wif-from-private-key.py 2ndkey &gt;&gt; mytextfile.txt
...
</code></pre>
<hr />
<p>PS: there're two ways of produce the WIF from a private key (compressed and uncompressed): any of them both will do the job.</p>

CC BY-SA 4.0
2020-06-24T23:13:46.013Z
2020-06-28T17:04:57.240Z
2020-06-28T17:04:57.240Z
circulosmeos
<p>Is there a python script that i could use to convert a list of private hex keys to there import format in bulk?</p>

<p>How would I go about this..</p>

<p>Could this be adjusted to take a .txt list of hex addresses and convert the to private import format, then print the results to a txt file?</p>

<pre><code>In [1]: import base58
In [2]: hexstring= "00010966776006953D5567439E5E39F86A0D273BEED61967F6"
In [3]: unencoded_string = bytes.fromhex(hexstring)
In [4]: encoded_string= base58.b58encode(unencoded_string)
In [5]: print(encoded_string)
16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM
</code></pre>

CC BY-SA 3.0
2015-11-28T18:49:15.720Z
can this be adjusted to take a list of hex addresses and then convert them to private import format and print results to a txt file?
ryan
<python>
Convert a list of 64 hex keys to private import format
ryan
# Convert a list of 64 hex keys to private import format

(Asked by: username_0 on 2015-11-28)

Is there a python script that i could use to convert a list of private hex keys to there import format in bulk?

How would I go about this..

Could this be adjusted to take a .txt list of hex addresses and convert the to private import format, then print the results to a txt file?

```
In [1]: import base58
In [2]: hexstring= "00010966776006953D5567439E5E39F86A0D273BEED61967F6"
In [3]: unencoded_string = bytes.fromhex(hexstring)
In [4]: encoded_string= base58.b58encode(unencoded_string)
In [5]: print(encoded_string)
16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM

```

**Tags:** python

> **Comments:**
> **username_0**: can this be adjusted to take a list of hex addresses and then convert them to private import format and print results to a txt file?  

---

## 2 answers

### Answer by username_1 on 2015-12-01. Score: 1

You should consider using this (or a similar) python library to import your keys, as straight conversion from hex to base58 can have a few gotchas:

<https://github.com/vbuterin/pybitcointools>

Check the examples in the README and you should be on your way to making your script.


---

### Answer by username_2 on 2020-06-24. Score: 0

You can use these little scripts in command line, so you don't have to program a single line (also run in Windows if you have Python), or easily modify them if you want:

**<https://github.com/username_2/bitcoin-in-tiny-pieces>**

For your private key example:

```
$ ./bitcoin-wif-from-private-key.py 00010966776006953D5567439E5E39F86A0D273BEED61967F6

privkey = 8000010966776006953D5567439E5E39F86A0D273BEED61967F6

For uncompressed public key:
checksum =      02d037e84dee212e14b823a8c9ac01409f6c1504e558d86116a4302d4d68bbdf
key + checksum =        8000010966776006953D5567439E5E39F86A0D273BEED61967F6 02d037e8
bitcoin address =       Sea2qLkneYfbTv29SLY8QvhkAZDxwgDfMuWprqj4b

For compressed public key:
checksum =      021538258480bbb46a846ef24bb2927d24f7c90bf354d76d6da3bd52c47e633d
key + checksum =        8000010966776006953D5567439E5E39F86A0D273BEED61967F601 02153825
bitcoin address =       2xCpo6NCGUimM7o24EqEPic2qXBEDvL6tKGne3Avisv

```

If you modifiy the script setting this variable to False, only WIF addresses are printed:

```
VERBOSE = False

```

(Once you have programmed the desired output) you can make a batch file (.sh in linux, .bat in Windows) with a command line per private key (an editor like [Sublime Text](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwjY_rmgyJvqAhUZA2MBHWY_BrIQjBAwAXoECAYQAg&url=https%3A%2F%2Fwww.sublimetext.com%2F3&usg=AOvVaw0BtVmjapIa9yP4qOnqEhSR) for example can edit and paste multiple lines at once, so it's easy) each appending to the a file, and the run this batch file:

```
./bitcoin-wif-from-private-key.py 1stkey >> mytextfile.txt
./bitcoin-wif-from-private-key.py 2ndkey >> mytextfile.txt
...

```

---

PS: there're two ways of produce the WIF from a private key (compressed and uncompressed): any of them both will do the job.


---

