Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: MGF15 on December 10, 2015, 04:46:50 PM



Title: PyBTC Bitcoin Address's Generator (offline) and More
Post by: MGF15 on December 10, 2015, 04:46:50 PM
Hello all this my first Post Here  :D :D

PyBTC it's Simple (script & library)

Bitcoin Address's Generator (offline) , Base58Check (WIF) Encode/Decode , WIF to Bitcoin Address

Ex for using as library
Code:
    >>> from PyBTC import Addr
    >>> Addr('0000000000000000000000000000000000000000000000000000000000000002')
    '1LagHJk2FyCV2VzrNHVqg3gYG4TSYwDV4m'

WIF
Code:
    >>> from PyBTC import WIF
    >>> WIF('0000000000000000000000000000000000000000000000000000000000000002')
    '5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAvUcVfH'

Ex as script

Code:

PyBTC.py -a
Address :  1LTUNrDmDZTDJxy3PviZxjwDJpvUr2YRu7
Privkey :  3427e5ca8a4b34f2c057b6ebd4372b6a86b6c8ad16831cce7cf5b53bcefc637e
WIF     :  5JDFqFTFDEfvzuxrQrSrvnrTHJKqeTdcNTxWMCQ2VotLZTfPw7v

source  ;D https://github.com/MGF15/PyBTC/ (https://github.com/MGF15/PyBTC/)


Title: Re: PyBTC Bitcoin Address's Generator (offline) and More
Post by: cr1776 on December 10, 2015, 05:13:15 PM
One concern I'd have is with the PRNG that is in use.  

:-)
e.g.
Code:
def rankey():
rand = random.randint(0x00000,0xfffff)
key = sha256(str(rand).encode('hex')).hexdigest()
return key

Hello all this my first Post Here  :D :D

PyBTC it's Simple (script & library)
...



Title: Re: PyBTC Bitcoin Address's Generator (offline) and More
Post by: MGF15 on December 10, 2015, 05:35:18 PM
 :D :D

i'm a n00b its jsut random kay and encode it in hex and sha256 to get 32-bit key and use it as a private key :)


Title: Re: PyBTC Bitcoin Address's Generator (offline) and More
Post by: Newar on December 10, 2015, 05:36:23 PM

May be helpful: https://bitcointalk.org/index.php?topic=361092.0


Title: Re: PyBTC Bitcoin Address's Generator (offline) and More
Post by: MGF15 on December 10, 2015, 05:43:12 PM
also you can use your private key  ;) so don't worry


Title: Re: PyBTC Bitcoin Address's Generator (offline) and More
Post by: cr1776 on December 10, 2015, 06:13:49 PM
also you can use your private key  ;) so don't worry

You should not rely on this code if the part I am looking it is accurate.
You are picking a number between 0 and 0xfffff (1,048,575)
Code:
rand = random.randint(0x00000,0xfffff)

That is not large enough and could be searched in seconds - meaning your coins will be stolen.

You should fix the code.


Title: Re: PyBTC Bitcoin Address's Generator (offline) and More
Post by: MGF15 on December 10, 2015, 06:20:37 PM
oh  :o thanx i'll fix it


Title: Re: PyBTC Bitcoin Address's Generator (offline) and More
Post by: cr1776 on December 10, 2015, 06:56:43 PM
oh  :o thanx i'll fix it

If you look at the link Newar sent, I think it has a reasonable PRNG in there - I didn't look to see though.

This is a good way to learn about bitcoin, for sure.  ;-)


Title: Re: PyBTC Bitcoin Address's Generator (offline) and More
Post by: MGF15 on December 10, 2015, 07:09:13 PM
 ;D Done update it

Code:
def rankey():
r = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()"0123456789'
rand = random.sample(r,64)
k = ''.join(rand)
key = sha256(k).hexdigest()
return key