Created
March 17, 2021 08:40
-
-
Save ltpquang/05d04595e232e491c4cebc5818f1c4ee to your computer and use it in GitHub Desktop.
Python3 script to genenerate ETH wallet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import codecs | |
import os | |
import csv | |
import ecdsa | |
from Crypto.Hash import keccak | |
def gen(): | |
private_key_bytes = os.urandom(32) | |
key = ecdsa.SigningKey.from_string(private_key_bytes, curve=ecdsa.SECP256k1).verifying_key | |
key_bytes = key.to_string() | |
private_key = codecs.encode(private_key_bytes, 'hex') | |
public_key = codecs.encode(key_bytes, 'hex') | |
public_key_bytes = codecs.decode(public_key, 'hex') | |
h = keccak.new(digest_bits=256) | |
h.update(public_key_bytes) | |
keccak_digest = h.hexdigest() | |
address = '0x' + keccak_digest[-40:] | |
# print("Private key: ", private_key.decode()) | |
# print("Public key: ", public_key.decode()) | |
# print("Address:", address) | |
return address, public_key, private_key | |
def main(): | |
with open('wallets.csv', 'w', newline='') as csvfile: | |
w = csv.writer(csvfile, delimiter=',', | |
quotechar='|', quoting=csv.QUOTE_MINIMAL) | |
for i in range(10000): | |
address, public_key, private_key = gen() | |
w.writerow([address, public_key.decode(), private_key.decode()]) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment