How do I get the account Id given a Principal?

I was following the thread to create an account Id given a Principal (and sub-account) in order to interface with the ledger canister: How to get the Account Identifier from Principal in Motoko?

I was using this repo for account Id: GitHub - stephenandrews/motoko-accountid
It returns a [Nat8], and now I need to convert that to an account Id. The repo mentions to use the “hex library” to get the final Text representation, but I’m not sure what library to use.

I’ve tried both GitHub - enzoh/motoko-hex: The Hex Package and GitHub - kritzcreek/mo-hex: Hexadecimal encoding and decoding routines., but both seem to be outdated?

2 Likes