using System.Collections.Generic;
using System.Security.Cryptography;
private const int DEFAULT_STEP = 252;
private const int FACTOR = 4;
public static void Main()
string seed = "frYpfgvOiHYuENamet#vaWZRk8W$quc4";
string totp = GeneratePassword(seed, timestamp);
public static string GeneratePassword(string seed, long time, int step = DEFAULT_STEP / FACTOR)
IncrementalHash sha256 = IncrementalHash.CreateHash(HashAlgorithmName.SHA256);
int factor = step * FACTOR / 60;
sha256.AppendData(Encoding.UTF8.GetBytes(seed));
sha256.AppendData(Encoding.UTF8.GetBytes((time / factor).ToString()));
return Convert.ToBase64String(sha256.GetHashAndReset());