> For the complete documentation index, see [llms.txt](https://guide.mmdrza.com/guidelines/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guide.mmdrza.com/guidelines/secp256k2/convert-private-key-to-wif-compressed-and-uncompressed.md).

# Convert Private Key To Wif Compressed and Uncompressed

```python
from secp256k2 import Contactor

cont = Contactor()

privatekey = "PRIVATE_KEY_HERE"

wif_compress = cont.btc_pvk_to_wif(privatekey, True)

wif_uncompress = cont.btc_pvk_to_wif(privatekey, False)
```

Once you have your private key, you can easily convert it to its Wallet Import Format (WIF) using the `btc_pvk_to_wif` function. This function can generate both compressed and uncompressed WIF formats. The choice between them depends on your specific requirements.

To convert the private key to the compressed WIF format:

```python
wif_compress = cont.btc_pvk_to_wif(privatekey, True)
```

And for the uncompressed WIF format:

```python
wif_uncompress = cont.btc_pvk_to_wif(privatekey, False)
```

The `True` or `False` parameter passed to the function designates whether the resulting WIF should be compressed or uncompressed, respectively. It's crucial to know which format is expected by the services or wallets you plan to use.
