Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

157
Vistas
JS decryption method translate to C#

I need some help with JS code translation to C#. JS Code:

function Decription(string) {
            var newString = '',
                char, codeStr, firstCharCode, lastCharCode;
            var ft = escape(string);
            string = decodeURIComponent(ft);
            for (var i = 0; i < string.length; i++) {
                char = string.charCodeAt(i);
                if (char > 132) {
                    codeStr = char.toString(10);
                    firstCharCode = parseInt(codeStr.substring(0, codeStr.length - 2), 10);
                    lastCharCode = parseInt(codeStr.substring(codeStr.length - 2, codeStr.length), 10) + 31;
                    newString += String.fromCharCode(firstCharCode) + String.fromCharCode(lastCharCode);
                } else {
                    newString += string.charAt(i);
                }
            }
            return newString;
        }

And I tied to translate on C#:

private string Decription(string encriptedText)
        {
            string ft = Regex.Escape(encriptedText);
            string text = HttpUtility.UrlDecode(ft);
            string newString = "";

            for (int i = 0; i < text.Length; i++)
            {
                var ch = (int)text[i];
                if(ch > 132)
                {
                    var codeStr = Convert.ToString(ch, 10);
                    var firstCharCode = Convert.ToInt32(codeStr.Substring(0, codeStr.Length - 2), 10);
                    var lastCharCode = Convert.ToInt32(codeStr.Substring(codeStr.Length - 2, codeStr.Length), 10) + 31;
                }
            }

        }

But how I can translate this row:

newString += String.fromCharCode(firstCharCode) + String.fromCharCode(lastCharCode);

Maybe do you know equivalent method to String.fromCharCode() on C# ?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Here you go:

public static void Main()
{
    // from 97 to a
    int i = 97;
    Console.WriteLine(StringFromCharCode(97));
}

public static string StringFromCharCode(int code) => ((char)code).ToString();

Demo

Note that you may want to use a StringBuilder instead of concatening string in your case.

Related to Int to Char in C# (Read it. It includes a nice comment about cast vs Convert.ToChar)

over 4 years ago · Santiago Trujillo Denunciar

0

You can simply use Convert.ToChar method, Convert.ToChar(97) will return a.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda