a UTF-8 RFC-compliant cryptographic hashing library for Udon
See it in VRChat


You can copy UdonHashLib サイコー into here to check these hashes.

Supported hash algorithms

Algorithm Variant Supported
MD MD5
SHA1 SHA1
SHA2 SHA224
SHA256
SHA384
SHA512
SHA512/224
SHA512/256
SHA3 SHA3-224
SHA3-256
SHA3-384
SHA3-512
SHAKE128
SHAKE256

How to use

Download the latest release from the releases page.

You need the latest VRCSDK3-WORLD and a copy of UdonSharp.

To use the library in your scene, either drag an instance of the UdonHashLib prefab into the scene, or add the UdonBehaviour component to an existing object and give it the UdonHashLib program source.

You only need to have one instance of UdonHashLib in your world. The library object is stateless, and so it is safe for multiple behaviors or objects to use it at once.

Once it is in your scene, you must add a field to your behavior to reference the library, like so:

[SerializeField]
private UdonHashLib _hashLibrary;

Make sure you set the field to reference the UdonHashLib prefab, or whichever object holds the program:

You can then use the library from that behavior as described below.

API reference

Function Description
_hashLibrary.MD5_Bytes(byte[] data) -> string Taking in either an array of bytes or a string (which will be interpreted as UTF-8), this function returns the MD5 hash as hexadecimal.

Please note that the MD5 algorithm is known to have collisions. For real security purposes, it is recommended to use a newer algorithm.
_hashLibrary.MD5_UTF8(string text) -> string
_hashLibrary.SHA1_Bytes(byte[] data) -> string Taking in either an array of bytes or a string (which will be interpreted as UTF-8), this function returns the SHA1 hash as hexadecimal.

Please note that the SHA1 algorithm is known to have collisions. For real security purposes, it is recommended to use a newer algorithm.
_hashLibrary.SHA1_UTF8(string text) -> string
_hashLibrary.SHA224_Bytes(byte[] data) -> string Taking in either an array of bytes or a string (which will be interpreted as UTF-8), this function returns the SHA224 hash as hexadecimal.
_hashLibrary.SHA224_UTF8(string text) -> string
_hashLibrary.SHA256_Bytes(byte[] data) -> string Taking in either an array of bytes or a string (which will be interpreted as UTF-8), this function returns the SHA256 hash as hexadecimal.
_hashLibrary.SHA256_UTF8(string text) -> string
_hashLibrary.SHA384_Bytes(byte[] data) -> string Taking in either an array of bytes or a string (which will be interpreted as UTF-8), this function returns the SHA384 hash as hexadecimal.
_hashLibrary.SHA384_UTF8(string text) -> string
_hashLibrary.SHA512_Bytes(byte[] data) -> string Taking in either an array of bytes or a string (which will be interpreted as UTF-8), this function returns the SHA512 hash as hexadecimal.
_hashLibrary.SHA512_UTF8(string text) -> string

FAQ

Why is there no SHA3 support?

While MD5, SHA1, and SHA2 operate on a similar 'load, extend, compress' principle, SHA3 is a newer standard that uses something called cryptographic sponge construction.

This makes it much more difficult to implement, as it would effectively require an entirely different internal code design.

At the moment, SHA3 is very scarcely used and SHA2 is still considered secure enough for cryptographic applications. I may implement SHA3 in the future, but for now this library mostly tends to the practical cases.

Does this support Unicode?

Yes, it does. This means you can safely use e.g. player usernames in your inputs and get the correct output.

Udon does not actually natively expose encoding functions, so a mini-implementation of the conversion is included with the library.

How fast is it?

The world linked in the header shows a demo of the library in action.

Inside the world, there is a display that picks a random word and hashes it using all 6 algorithms twice every second.

In my testing, the world never drops below 88fps (with 90fps being the cap). Considering frame timing, this effect will be even less noticeable in worlds with framerates below the cap. It is also unlikely you will be hashing 12 times a second in practical applications, so in short, I'd say "fast enough that you'll never need to worry about it".

Acknowledgements

The library itself does not use or require anything but Udon and UdonSharp.

This README and the sample world uses the Udon logo, which is property of VRChat Inc.