The authenticate function is the foundation of the Truvideo SDK. It securely initiates a session and prepares the SDK for capturing, uploading, and editing media.
This guide will walk you through integrating authentication into your project using the Truvideo Core Module.
Authentication Integration Guide
Prerequisites
Before you begin:
Make sure the Core module is integrated. See Installation
Request your API Key and Secret Key from Truvideo.
#if IOS
using UIKit;
using Foundation;
using TruvideoCameraiOS;
#endif
#if ANDROID
using Application = Android.App.Application;
using TruVideoCoreAndroidBinding;
using TruVideoCoreLib = TruVideoCoreAndroid.DotnetCoreTruvideo;
#endif
using System.Security.Cryptography;
using System.Text;
namespace TruVideoSampleApp;
public static class HashHelper
{
public static string? ToSha256String(string signature, string payload)
{
try
{
var keyBytes = Encoding.UTF8.GetBytes(signature);
var payloadBytes = Encoding.UTF8.GetBytes(payload);
using var hmac = new HMACSHA256(keyBytes);
var hashBytes = hmac.ComputeHash(payloadBytes);
// Convert to hex string
var hexString = new StringBuilder();
foreach (var b in hashBytes) hexString.Append(b.ToString("x2")); // formats byte as lowercase hex
return hexString.ToString();
}
catch (Exception ex)
{
// Log or handle exception as needed
Console.WriteLine(ex);
return null;
}
}
}