Skip to content

Commit

Permalink
remove duplicate functions defintions
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy Lee authored and Timothy Lee committed May 13, 2019
1 parent 3dd849f commit 4abddfb
Showing 1 changed file with 22 additions and 30 deletions.
52 changes: 22 additions & 30 deletions kt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2062,21 +2062,6 @@
256: ''.join([chr(x) for x in range(256)])
}

def bin_dbl_sha256(s):
bytes_to_hash = from_string_to_bytes(s)
return hashlib.sha256(hashlib.sha256(bytes_to_hash).digest()).digest()

def get_code_string(base):
if base in code_strings:
return code_strings[base]
else:
raise ValueError("Invalid base!")

def changebase(string, frm, to, minlen=0):
if frm == to:
return lpad(string, get_code_string(frm)[0], minlen)
return encode(decode(string, frm), to, minlen)

def bin_to_b58check(inp, magicbyte=0):
while magicbyte > 0:
inp = chr(int(magicbyte % 256)) + inp
Expand Down Expand Up @@ -2134,21 +2119,6 @@ def decode(string, base):
256: ''.join([chr(x) for x in range(256)])
}

def bin_dbl_sha256(s):
bytes_to_hash = from_string_to_bytes(s)
return hashlib.sha256(hashlib.sha256(bytes_to_hash).digest()).digest()

def get_code_string(base):
if base in code_strings:
return code_strings[base]
else:
raise ValueError("Invalid base!")

def changebase(string, frm, to, minlen=0):
if frm == to:
return lpad(string, get_code_string(frm)[0], minlen)
return encode(decode(string, frm), to, minlen)

def bin_to_b58check(inp, magicbyte=0):
while magicbyte > 0:
inp = from_int_to_byte(magicbyte % 256) + inp
Expand Down Expand Up @@ -2227,6 +2197,28 @@ def extract(d, cs):

return result


def bin_dbl_sha256(s):
bytes_to_hash = from_string_to_bytes(s)
return hashlib.sha256(hashlib.sha256(bytes_to_hash).digest()).digest()

def lpad(msg, symbol, length):
if len(msg) >= length:
return msg
return symbol * (length - len(msg)) + msg

def get_code_string(base):
if base in code_strings:
return code_strings[base]
else:
raise ValueError("Invalid base!")

def changebase(string, frm, to, minlen=0):
if frm == to:
return lpad(string, get_code_string(frm)[0], minlen)
return encode(decode(string, frm), to, minlen)


def b58check_to_bin(inp):
leadingzbytes = len(re.match('^1*', inp).group(0))
data = b'\x00' * leadingzbytes + changebase(inp, 58, 256)
Expand Down

0 comments on commit 4abddfb

Please sign in to comment.