Python Forum
Hi all any help with this python code please
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hi all any help with this python code please
#2
I'd like to help. But I don't understand what you want. So do you want the program to return false if an incorrect address is entered and true if a correct address is entered?

In that case, this would probably work.

from hashlib import sha256
  
digits58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
  
def decode_base58(bc, length):
    n = 0
    for char in bc:
        n = n * 58 + digits58.index(char)
    return n.to_bytes(length, 'big')
def check_bc(bc):
    try:
        bcbytes = decode_base58(bc, 25)
        if bcbytes[-4:] == sha256(sha256(bcbytes[:-4]).digest()).digest()[:4]:
            return True
        else:
            return False
    except Exception as e:
        return e #this line is just returning the exception
  
print(check_bc('1AGNa15ZQXAZUgFiqJ3i7Z2DPU2J6hW62i'))
print(check_bc("17NdbrSGoUotzeGCcMMCqnFkEvLymoou9j"))
That fixes the true-false issue. (Hopefully)
Now for the loop are these keys stored in a file? reply so i can help you.
Don't doubt always question. There's a difference.
Reply


Messages In This Thread
RE: Hi all any help with this python code please - by tannishpage - Mar-21-2018, 10:27 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020