<p>I took a script to translate the bitcoin address to hash160:<br>
<a href="http://lenschulwitz.com/b58/base58perl.txt" rel="nofollow noreferrer">http://lenschulwitz.com/b58/base58perl.txt</a><br>
replaced the lines for working with the list from the file:</p>

<pre><code>#Sample test taken from https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses.
my $base58_encoded_address = "16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM";
print "\nRunning tests for bitcoin address $base58_encoded_address\n";
print "Bitcoin address is valid.  Address type: '", check_bitcoin_address($base58_encoded_address), "'.\n";
my $binary_address = decodebase58tohex($base58_encoded_address);
print "Binary hexadecimal representation is: $binary_address\n";
my $reencoded_base58 = encodebase58fromhex($binary_address);
print "Re-encoded back to Base58 is: $reencoded_base58\n\n";
</code></pre>

<p>to:</p>

<pre><code>my $fileSrc = 'base58.txt';
open my $fhSrc, $fileSrc or die "Could not open $fileSrc: $!";

my $fileDest = 'hex.txt';
open(my $fhDest, '&gt;&gt;', $fileDest) or die "Could not open file $fileDest: $!";

while( my $base58_encoded_address = &lt;$fhSrc&gt;)  {   
  my $binary_address = decodebase58tohex($base58_encoded_address);
  say $fhDest $binary_address, 2, 40;
}

close $fhSrc;
close $fhDest;
</code></pre>

<p>But this script stops and does not work with bech32 addresses, tell me what needs to be added so that it works with bech32. Or maybe someone has a similar script for converting addresses for the brainflayer?</p>

CC BY-SA 4.0
2021-01-05T06:09:33.347Z
Have you solved this problem now?
邹云开
CC BY-SA 4.0
2021-02-12T08:54:46.250Z
I didn't solve this problem :)
Private Person
<bech32-address><base58>
Bitcoin address to Hash160 for brainflayer
Private Person
# Bitcoin address to Hash160 for brainflayer

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

I took a script to translate the bitcoin address to hash160:  
<http://lenschulwitz.com/b58/base58perl.txt>  
replaced the lines for working with the list from the file:

```
#Sample test taken from https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses.
my $base58_encoded_address = "16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM";
print "\nRunning tests for bitcoin address $base58_encoded_address\n";
print "Bitcoin address is valid.  Address type: '", check_bitcoin_address($base58_encoded_address), "'.\n";
my $binary_address = decodebase58tohex($base58_encoded_address);
print "Binary hexadecimal representation is: $binary_address\n";
my $reencoded_base58 = encodebase58fromhex($binary_address);
print "Re-encoded back to Base58 is: $reencoded_base58\n\n";

```

to:

```
my $fileSrc = 'base58.txt';
open my $fhSrc, $fileSrc or die "Could not open $fileSrc: $!";

my $fileDest = 'hex.txt';
open(my $fhDest, '>>', $fileDest) or die "Could not open file $fileDest: $!";

while( my $base58_encoded_address = <$fhSrc>)  {   
  my $binary_address = decodebase58tohex($base58_encoded_address);
  say $fhDest $binary_address, 2, 40;
}

close $fhSrc;
close $fhDest;

```

But this script stops and does not work with bech32 addresses, tell me what needs to be added so that it works with bech32. Or maybe someone has a similar script for converting addresses for the brainflayer?

**Tags:** bech32-address, base58

> **Comments:**
> **username_1**: Have you solved this problem now?  
> **username_0**: I didn't solve this problem :)  

---

## 0 answers

