Bitcoin Forum
September 19, 2019, 10:01:20 AM *
News: Latest Bitcoin Core release: 0.18.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: convert list of bitcoin address to hash 160 ??? Python  (Read 121 times)
Jupiter_01
Member
**
Offline Offline

Activity: 106
Merit: 15


View Profile
October 19, 2018, 06:42:47 AM
 #1

input.txt

adres
1KxUVU9DKfdaTLMnXBLS5BZRf56cFnRosk
1KxUVU9DKfdaTLMnXBLS5BZRf56cFnRosk
1KxUVU9DKfdaTLMnXBLS5BZRf56cFnRosk
1KxUVU9DKfdaTLMnXBLS5BZRf56cFnRosk
1KxUVU9DKfdaTLMnXBLS5BZRf56cFnRosk
1KxUVU9DKfdaTLMnXBLS5BZRf56cFnRosk
....
....
....


output.txt
hash 160
cff01716e3b722613b3d017b9ed5da84d24e4fcf
cff01716e3b722613b3d017b9ed5da84d24e4fcf
cff01716e3b722613b3d017b9ed5da84d24e4fcf
cff01716e3b722613b3d017b9ed5da84d24e4fcf
cff01716e3b722613b3d017b9ed5da84d24e4fcf
cff01716e3b722613b3d017b9ed5da84d24e4fcf
....
....
....



How to convert in python??
1568887280
Hero Member
*
Offline Offline

Posts: 1568887280

View Profile Personal Message (Offline)

Ignore
1568887280
Reply with quote  #2

1568887280
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1568887280
Hero Member
*
Offline Offline

Posts: 1568887280

View Profile Personal Message (Offline)

Ignore
1568887280
Reply with quote  #2

1568887280
Report to moderator
1568887280
Hero Member
*
Offline Offline

Posts: 1568887280

View Profile Personal Message (Offline)

Ignore
1568887280
Reply with quote  #2

1568887280
Report to moderator
bob123
Legendary
*
Offline Offline

Activity: 1022
Merit: 1515



View Profile WWW
October 19, 2018, 06:50:59 AM
 #2

Why do you want to hash the address ? The address is a hash itself.

But alright.. whatever..  First, you need to define what hash function you want to use. I can only see "hash 160".
There is no "hash 160".

I guess you are referring to the RIPEMD-160.. ?


You can use hashlib:

Code:
>>> h = hashlib.new('ripemd160')
>>> h.update(b"YourString or address or whatever")
>>> h.hexdigest()

Output will be the RIPEMD-160 hash of the input.


But the chances are high you are trying to accomplish something which doesn't help you at all.
Instead of asking how to do that particular step, start from the beginning and explain what you are trying to accomplish (and please explain detailed why you need to hash the hash of a public key, it doesn't make sense for me).

Jupiter_01
Member
**
Offline Offline

Activity: 106
Merit: 15


View Profile
October 19, 2018, 07:03:19 AM
 #3


I want to create a database. for a project. need to convert address list...
bob123
Legendary
*
Offline Offline

Activity: 1022
Merit: 1515



View Profile WWW
October 19, 2018, 07:08:03 AM
 #4

I want to create a database. for a project. need to convert address list...

You aren't converting addresses this way. You are simply hashing them.
And since addresses already are RIPEMD-160 hashes, they won't get shorter (or whatever you are expecting to happen).


My previous post explained how to do this based on an example. Implementing it for a list of addresses shouldn't be a problem at all anymore.

pooya87
Legendary
*
Offline Offline

Activity: 1764
Merit: 1880


Remember tonight for it's the beginning of forever


View Profile
October 19, 2018, 06:25:49 PM
Merited by HeRetiK (1)
 #5

But alright.. whatever..  First, you need to define what hash function you want to use. I can only see "hash 160".
There is no "hash 160".

hash160 is referred to the result of RIPEMD160 of SHA256 which is the first step used to convert public key to an address:
Code:
base58check({version byte}RIPEMD160(SHA256(pubkey)))

Base58check encoding is encoding so it is reversible function. so to get HASH160 simply decode the address (base58 string) then remove the first byte since it is the address version byte then remove the last 4 bytes if the function hasn't already done it since it is the checksum. the remaining 20 bytes will be HASH160.

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!