public string CifReverseSubstring(string texto, int enc)
{
string final = "";
if (enc == 2)
{
texto = Reverse(texto);
}
for (int i = 0; i < texto.Length; i += 2)
{
try
{
final += Reverse(texto.Substring(i, 2));
}
catch
{
final += texto.Substring(texto.Length - 1, 1);
}
}
if (enc == 1)
{
final = Reverse(final);
}
return final;
}
public static string Reverse(string texto)
{
string final = "";
for (int i = texto.Length - 1; i >= 0; i--)
final += texto.Substring(i, 1);
return final;
}
En uso:
string Texto = "Buenas noches UdTools.net!";
Texto = CifReverseSubstring(Texto, 2);// = "t!nes.olToUds heoc nasenBu";
Tool:[Enlace externo eliminado para invitados]