public static bool IsBase64(string input) { return (input.Length % 4) == 0 && Regex.IsMatch(input, "^[A-Z0-9/+=]*$", RegexOptions.IgnoreCase); } public static string Base64Encode(string input) { return Convert.ToBase64String(Encoding.UTF8.GetBytes(input)); } public static string Base64Decode(string input) { return Encoding.UTF8.GetString(Convert.FromBase64String(input)); }