use binascii.unhexlify() in Jinja2 template

HI!

I'm using stat task to let ansible calculate the SHA-512 checksum of a
file on the managed node [1] which returns hex-encoded hash values.

Now I have to convert the checksum to bytes prior to base64-encoding
this byte string.

In Python code I would use the function binascii.unhexlify(). But how to
do this in a Jinja2 template?

(I'm doing this to implement Subresource Integrity [3].)

Thanks in advance.

Ciao, Michael.

[1] https://docs.ansible.com/ansible/latest/modules/stat_module.html

[2] https://docs.python.org/3/library/binascii.html#binascii.unhexlify

[3]
https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity