January 12, 2020

🔑 SHA256 hash algorithm Prefab in Udon for VRChat

🔑 SHA256 hash algorithm Prefab in Udon for VRChat

This is a drag-and-drop SHA256 Prefab for VRChat worlds made in Unity 2018.14.x and SDK3 with Udon, allowing you to use SHA256 in your Udon programs.

A hash algorithm is a mathematical one-way function which takes an input string and outputs unrecognizable data. This is commonly used to store passwords, rather than storing passwords in cleartext you should store it's hash, and then at login hash the user's input and compare the two. Hash algorithms are also used to easier validate that the contents of a file is unchanged. Changing a single character will completely change the hash.

📥 Download:

The download contains two versions, one Graph version and one U# version. U# version is 2.5 times faster but requires UdonSharp installed. Graph version does not require any dependencies. Please feel free to ask if any questions! @Foorack

Download latest version
Download version 2020.02.29.11.26
Download version 2020.01.12.13.37

Update 2020.02.29.11.26: Project was rewritten in UdonSharp, which significantly speeded it up and computing SHA256 is now 2.5 times faster!

✨ YouTube Setup Tutorial

YouTube tutorial on how to use this, as well as the Keypab prefab is coming as soon as I've gotten my new setup configured. Will probably be a couple of days.

📑 Instructions on Usage

This module has pretty easy usage. It has 2 public string variables, input and output and a method called digest. Do the following to compute a SHA256 hash:

0. Declare a public UdonBehaviour variable, and set its value in the Inspector to the SHA256 prefab object.

1. Set the input string program variable on the SHA256 behaviour to the text you want to hash using SetProgramVariable.

2. Call the custom event on the SHA256 behaviour called digest using SendCustomEvent.

3. Finally fetch the result by reading the output variable with GetProgramVariable on the SHA256 UdonBehaviour.

Demo example on how to use the SHA256 module

There is a Usage_Example file included in the prefab. Assign this to any gameobject and it will run at startup. Each call on average takes 45-55 ms, although the first call takes slightly longer due to it initializing constants. This has been optimized as much as possible, and is hitting the current performance limits of Udon Alpha.

💙 Have fun! Can you find any use for this in VRChat?!

You are free to use this prefab without having to credit me. But if you do use it, I would love it if you told me what the hell this can be used for??.

A quick comment hearing the time I put in actually helped someone really gives motivation to continue updating and improving this, as well as continue making other stuff public. Thank you!