0

enter image description here

https://brainwalletx.github.io/#converter, 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf

This private key is generated from 1

If i do this other way on this same site, It gives me different result

enter image description here I want a formula to convert This 1 into this private key(5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf) in python Anyone knows formula or python code to do this ?

1
1

Using this Python library (I am the author)

>>> from cryptotools import PrivateKey
>>> i = 1
>>> prv = PrivateKey(i.to_bytes(32, ‘big’))
>>> prv.wif()
‘5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf‘
5
  • Thanks , Exactly what i needed Aug 10 '21 at 13:13
  • This code gets compressed key, Is there anyway to get Uncompressed from same way. Thanks Aug 10 '21 at 14:47
  • The code above is uncompressed. For compressed use prv.wif(compressed=True)
    – Mike D
    Aug 10 '21 at 14:59
  • It gives me different result for compressed key for example [1]: i.stack.imgur.com/Ydbhn.png This key is 769 But the script give me this key [2]: i.stack.imgur.com/48GFY.png What am i doing wrong What change do i have to do to get KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU74sHUHy8S , from i = 769 Aug 10 '21 at 19:17
  • I think the brainwallet site is padding to 33 bytes in the last screenshot so replace 32 with 33
    – Mike D
    Aug 10 '21 at 21:23
1

If i do this other way on this same site, It gives me different result

Try entering 0000000000000000000000000000000000000000000000000000000000000001 and selecting Hex at the top and Base58check at the bottom.

brainwallet webpage


I want a formula to convert This 1 into this private key (5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf) in python

https://www.google.com/search?q=python+base58check leads to https://pypi.org/project/base58check/ and many others.

Note that these libraries require that your value 1 be expressed as a byte array, not as a single decimal integer.


Remember that what you are seeing is not conversion of a single number into a private key but simply the same number presented in two different representations. That is, two different encodings. Note also that encoding is not encryption.

  • 1 is the same number as 0x01 even though the latter is encoded as hexadecimal.

  • 1 is the same number as 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf even though the latter is encoded as Base58check.

1
  • Any idea how can i convert 1 into the byte array and then convert that bye array into the privatekey 5HpHag...... I want to do all of these in python Aug 10 '21 at 12:20
0

You can also do it "from scratch" with just hashlib, binascii and base58 modules:

import hashlib, binascii, base58

pkeyhash = "0000000000000000000000000000000000000000000000000000000000000001"

pkeyvbytes = "80"+pkeyhash

firsthash = hashlib.sha256(binascii.unhexlify(pkeyvbytes)).hexdigest()

secondhash = hashlib.sha256(binascii.unhexlify(firsthash)).hexdigest()

createkey = pkeyvbytes+secondhash[:8]

WIF = base58.b58encode(binascii.unhexlify(createkey))

print(WIF)

>>> 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.