Skip to content

Instantly share code, notes, and snippets.

@kdssoftware
Created June 20, 2023 12:27
Show Gist options
  • Save kdssoftware/af9e9051a5c9562be0a6f98e737c4bd8 to your computer and use it in GitHub Desktop.
Save kdssoftware/af9e9051a5c9562be0a6f98e737c4bd8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import hashlib
import base58
def sha256(hexstr):
"""sha256 hash algorithm
"""
return hashlib.new('sha256', bytes.fromhex(hexstr)).hexdigest()
def rip160(hexstr):
"""ripemd160 hash algorithm
"""
return hashlib.new('ripemd160', bytes.fromhex(hexstr)).hexdigest()
def get_ltc_address(pubkey):
"""https://bitcoin.stackexchange.com/questions/65282/how-is-a-litecoin-address-generated
"""
rip160_hash = "30" + rip160(sha256(pubkey.upper()).upper()).upper()
sha256_hash = sha256(sha256(rip160_hash).upper()).upper()
return base58.b58encode(bytes.fromhex(rip160_hash + sha256_hash[0:8]))
if __name__ == '__main__':
import sys
if len(sys.argv) != 2:
print("[*] Usage: python %s publickey")
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment