<p>Which kind of address do you want?</p>

<p>Assuming that you have compressed public key(<code>compressed_public_key.txt</code>), to generate <code>P2PKH</code> you can use these commands (hash160 and encoding with base58)</p>

<pre><code>  ADDR_RIPEMD160=$(printf $(cat compressed_public_key.txt | xxd -r -p | openssl sha256| sed 's/^.* //') |xxd -r -p | openssl ripemd160 | sed 's/^.* //')
  ADDR=`printf $VERSION_PREFIX_ADDRESS$ADDR_RIPEMD160 | xxd -p -r | base58 -c`
  echo $ADDR
</code></pre>

<p>Where <code>$VERSION_PREFIX_ADDRESS</code> for P2PKH addresss are <code>0x00</code> for mainnet or <code>0x6F</code> for testnet (<a href="https://en.bitcoin.it/wiki/List_of_address_prefixes" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/List_of_address_prefixes</a>)</p>

CC BY-SA 4.0
2020-05-04T12:44:49.623Z
I want an address for receiving bitcoin
Bob5421
CC BY-SA 4.0
2020-05-04T12:46:43.753Z
Which kind of address? P2PKH or P2SH or Native segwit or P2SH-embed segwit?
monkeyUser
CC BY-SA 4.0
2020-05-04T12:48:25.287Z
I don't really know. There are multiple kind of addresses for receiving bitcoins ?
Bob5421
CC BY-SA 4.0
2020-05-04T12:53:20.203Z
Multiply kind of script.
monkeyUser
CC BY-SA 4.0
2020-05-04T12:54:49.603Z
check this link bob https://en.bitcoin.it/wiki/Address
monkeyUser
CC BY-SA 4.0
2020-05-04T05:56:08.820Z
2020-05-04T07:42:15.037Z
2020-05-04T07:42:15.037Z
monkeyUser
<p>No, it is not possible to use openssl for generation of a bitcoin address from a public key, unfortunately. Bitcoin addresses require base58, bech32 or bech32m encoding which are not supported by OpenSSL.</p>

CC BY-SA 4.0
2022-08-22T11:28:41.860Z
2022-08-22T11:28:41.860Z
Greg Tonoski
<p>Is there a way to generate a bitcoin address from public key with openssl command line ?</p>

<p>Thanks</p>

<address><openssl>
Generate bitcoin address from public key file
Bob5421
# Generate bitcoin address from public key file

(Asked by: username_0 on 2020-05-03)

Is there a way to generate a bitcoin address from public key with openssl command line ?

Thanks

**Tags:** address, openssl


---

## 2 answers

### Answer by username_1 on 2020-05-04. Score: 4

Which kind of address do you want?

Assuming that you have compressed public key(`compressed_public_key.txt`), to generate `P2PKH` you can use these commands (hash160 and encoding with base58)

```
  ADDR_RIPEMD160=$(printf $(cat compressed_public_key.txt | xxd -r -p | openssl sha256| sed 's/^.* //') |xxd -r -p | openssl ripemd160 | sed 's/^.* //')
  ADDR=`printf $VERSION_PREFIX_ADDRESS$ADDR_RIPEMD160 | xxd -p -r | base58 -c`
  echo $ADDR

```

Where `$VERSION_PREFIX_ADDRESS` for P2PKH addresss are `0x00` for mainnet or `0x6F` for testnet (<https://en.bitcoin.it/wiki/List_of_address_prefixes>)

> **Comments:**
> **username_0**: I want an address for receiving bitcoin  
> **username_1**: Which kind of address? P2PKH or P2SH or Native segwit or P2SH-embed segwit?  
> **username_0**: I don't really know. There are multiple kind of addresses for receiving bitcoins ?  
> **username_1**: Multiply kind of script.  
> **username_1**: check this link bob https://en.bitcoin.it/wiki/Address  

---

### Answer by username_2 on 2022-08-22. Score: 0

No, it is not possible to use openssl for generation of a bitcoin address from a public key, unfortunately. Bitcoin addresses require base58, bech32 or bech32m encoding which are not supported by OpenSSL.


---

