Add support page, admin features, and auth hardening.
Rename public affiliate route to /support with localized nav labels, and include affiliate/social/wallpaper admin, 2FA login, and related site updates. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
202dc16a52
commit
fc45c35dbe
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Web.Security;
|
||||
|
||||
namespace atakanozbancom.Models.classes
|
||||
{
|
||||
public static class SecretProtector
|
||||
{
|
||||
private static readonly string[] Purposes = { "atakanozbancom.TotpSecret.v1" };
|
||||
|
||||
public static string Protect(string plaintext)
|
||||
{
|
||||
if (string.IsNullOrEmpty(plaintext))
|
||||
return plaintext;
|
||||
|
||||
var bytes = Encoding.UTF8.GetBytes(plaintext);
|
||||
var protectedBytes = MachineKey.Protect(bytes, Purposes);
|
||||
return Convert.ToBase64String(protectedBytes);
|
||||
}
|
||||
|
||||
public static string Unprotect(string protectedValue)
|
||||
{
|
||||
if (string.IsNullOrEmpty(protectedValue))
|
||||
return protectedValue;
|
||||
|
||||
try
|
||||
{
|
||||
var protectedBytes = Convert.FromBase64String(protectedValue);
|
||||
var bytes = MachineKey.Unprotect(protectedBytes, Purposes);
|
||||
return bytes == null ? null : Encoding.UTF8.GetString(bytes);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool LooksProtected(string value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
var bytes = Convert.FromBase64String(value);
|
||||
return bytes.Length > 16;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user