VRChat Udon OTP Library, HOTP(RFC 4226) & TOTP(RFC 6238).
Caution
This project is a personal learning exercise and serves as a demonstration of my learning outcomes. It is not intended for production environments or serious business applications. Use the code in this project at your own risk.
👇 Example video
- Unity 2022.3.6f1
- VRChat SDK - Worlds (Tested version: 3.5.2)
Contains a simple example that you can use however you want.
- Make sure you have imported the latest
VRChat SDK - Worlds
. - Download the latest release and import it into your project.
- Open the
_Gizmo/UdonOTPLib/Example/TOTP_Example.unity
scene. - You may need to import
TextMeshPro
. - Edit the
Secret
variable in theTOTP_Example
gameobject. (You can use totp-wasm.vercel.app to generateSecret
) - enjoy 🤓
Name | Type | Description |
---|---|---|
secret | string | Secret key encoded in base32 |
digits | int | Code digits |
period | int | Time period (seconds) |
t | double | Timestamp |
string secret = "2LESRALCTRW3B3J4WYSXFQYE5ZR6V5R2";
int digits = 6;
int period = 30;
// Get the code
string code = otp.TOTP(secret, otp.Timestamp(), digits, period);
Debug.Log($"Code: {code}");
// Countdown
int s = otp.Countdown(period);
Debug.Log($"Countdown: {s}sec");
Code is distributed under MIT license, feel free to use it in your proprietary projects as well.