Created
August 25, 2022 13:27
-
-
Save ChypherC0d3/daaa2c95d108c5e811325f9bfa0466e0 to your computer and use it in GitHub Desktop.
FastWalletCreator_LowEntropyHex.ipynb
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
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "FastWalletCreator_LowEntropyHex.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"authorship_tag": "ABX9TyONOuSiSbSKRw9KxVMEFfDw", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/CY0xZ/daaa2c95d108c5e811325f9bfa0466e0/fastwalletcreator_lowentropyhex.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"pip install eth_keys" | |
], | |
"metadata": { | |
"id": "Hnn6D4N9Lxsg" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"id": "VvvLNSl1LwhG" | |
}, | |
"outputs": [], | |
"source": [ | |
"from eth_keys import keys\n", | |
"from eth_utils import decode_hex\n", | |
"\n", | |
"def EntropyHex(z):\n", | |
"\n", | |
" import os\n", | |
" import hashlib # for SHA256 computation\n", | |
" import binascii # for conversion between Hexa and bytes\n", | |
" entropy = binascii.b2a_hex(os.urandom(z))\n", | |
" data = entropy.strip() # cleaning of data\n", | |
" data = binascii.unhexlify(data)\n", | |
" h = hashlib.sha256(data).hexdigest()\n", | |
" return h , entropy\n", | |
"\n", | |
"random_key, entropy = EntropyHex(1)\n", | |
"priv_key_bytes = decode_hex('0x'+random_key)\n", | |
"priv_key = keys.PrivateKey(priv_key_bytes)\n", | |
"pub_key = priv_key.public_key\n", | |
"\n", | |
"print(\"Entropy:\",entropy)\n", | |
"print(\"Random Key Generated:\",random_key)\n", | |
"print(\"Private Key:\", priv_key)\n", | |
"print(\"Public Key:\", pub_key)\n", | |
"print(\"Public Address:\", pub_key.to_checksum_address())" | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pip install eth-hash[pycryptodome]