Bitcoin Forum
May 08, 2024, 11:46:50 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: convert list of bitcoin address to hash 160 ??? Python  (Read 391 times)
Jupiter_01 (OP)
Member
**
Offline Offline

Activity: 122
Merit: 26


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??
1715212010
Hero Member
*
Offline Offline

Posts: 1715212010

View Profile Personal Message (Offline)

Ignore
1715212010
Reply with quote  #2

1715212010
Report to moderator
1715212010
Hero Member
*
Offline Offline

Posts: 1715212010

View Profile Personal Message (Offline)

Ignore
1715212010
Reply with quote  #2

1715212010
Report to moderator
1715212010
Hero Member
*
Offline Offline

Posts: 1715212010

View Profile Personal Message (Offline)

Ignore
1715212010
Reply with quote  #2

1715212010
Report to moderator
"If you don't want people to know you're a scumbag then don't be a scumbag." -- margaritahuyan
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



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 (OP)
Member
**
Offline Offline

Activity: 122
Merit: 26


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: 1624
Merit: 2481



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: 3444
Merit: 10555



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.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!