@page "/"
@using System.Text;
@inject NavigationManager navigator
Code
Here's your code
@* IMPORTANT: Take only 17 charecters from anywhere in the code!*@
@authCode
@if (verified)
{
Verified!
}
@code {
string authCode = "";
bool verified = false;
protected override async Task OnInitializedAsync()
{
string semiCode = GetCode();
string guess = semiCode.Skip(15).Take(17).ToString();
if (authCode.Contains(guess))
verified = true;
await Task.Delay(30000);
navigator.NavigateTo("", true);
}
public string GetCode()
{
var time = DateTime.Now;
Random random = new Random(time.Hour);
var sb = new StringBuilder();
for (int i = 0; i < 100; i++)
{
string salt = (i + random.NextDouble()).ToString();
sb.AppendLine(salt);
}
string semicode = Base64Encode(time.ToString("HH") + sb.ToString());
semicode = semicode.Trim('=');
authCode = semicode;
return semicode;
}
public static string Base64Encode(string plainText)
{
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
return System.Convert.ToBase64String(plainTextBytes);
}
}