How to calculate the Radix Resource Id (RRI) for a mutable token

Replace the public_key_hex with the public key used to create the token, and the symbol with the token symbol.

import bech32
import hashlib

public_key_hex = "02690937690ffb9d7ae8b67af05efc03a5a9f7e53933de80f92ce763a5554a1fa3"
symbol = b"rct"

public_key = bytearray.fromhex(public_key_hex)

m = hashlib.sha256()
m.update(public_key + symbol)
hash = m.digest()
n = hashlib.sha256()
hash2 = n.digest()

part = hash2[6:32]

readdr_bytes = b"\x03" + part
readdr_bytes5 = bech32.convertbits(readdr_bytes, 8 ,5)

resource_address = bech32.bech32_encode("rct_rr", readdr_bytes5)
print("Resource address: ", resource_address)

# rct_rr1q04fvesft0rsw9s66wrr0ccp30qwfysrdff67q2jxgvqxdcwfz

Run this code on Replit: