Hash of variable (rather than hash of file)?

I’d like to get the hash of a variable in a template/theme.

It is already possible to get the hash of a file using get_file_hash.

Is there already a way get the same but for a string variable?

If not, would a PR be accepted providing the functionality? I imagine something that would take identical arguments to the get_file_hash function.

I’m suggesting something like this:

{{ some_text | hash(sha_type=256) }}

Of course this wouldn’t have any extra dependencies because hashing functionality is already present.

All comments/insights appreciated!

Thanks