We currently use a python script to get fingerprints from assetName and policy id. However we are resorting to using the cardano bech32 binary for the final part of the process.
from hashlib import blake2b from subprocess import check_output import binascii import bech32 import sys policyId = '60a75d4bfee53ebe583679faed1fba8a8921abfd685dbc76e313032a' tokenId = '416433763173446576696c7331313739' binary_asset = binascii.unhexlify(policyId + tokenId) output = blake2b(binary_asset, digest_size=20).hexdigest() output = check_output([f"/home/bech32bin/bech32.sh", str(output)]).decode(sys.stdout.encoding).strip() print(output) ### output is asset1rgafp0kmehn9ws6g9224fyjd550wakdhlupk0k (correct)
Where the contents of bech32.sh are:
/home/bech32bin/bech32 asset <<< $1
This utilises the bech32 binary for the final stage of the process detailed in pseudocode here https://cips.cardano.org/cips/cip14/
Does anyone have an idea for a pythonic method of doing the last part. Without having to call a subprocess (which is slow, especially when looping through on potentially thousands of nfts) I assume with pythons inbuilt bech32 lib but have been unable to replicate.