Skip to content

Instantly share code, notes, and snippets.

@nazariyv
Created July 11, 2023 10:23
Show Gist options
  • Save nazariyv/88340bfac4673013ec11e5f54e0c9c5d to your computer and use it in GitHub Desktop.
Save nazariyv/88340bfac4673013ec11e5f54e0c9c5d to your computer and use it in GitHub Desktop.
throw away ethereum private key
import random
def int_to_privkey(n):
hex_n = hex(n)[2:] # convert to hexadecimal and strip the "0x" prefix
return hex_n.rjust(64, '0') # pad with zeros to the left until it's 64 characters long
int_to_privkey(random.randing(0, 2 ** 256 - 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment