Convert line from vb to C #

0

I have the following VB code

Funtion Encripta(ByVal Pass As String) As String
Dim Clave As String, i As Integer, Pass2 As String
Dim Car As String, Codigo As String
Clave="%ü&/@#$A"
Pass2=""
For i=1 to Len(Pass)
      CAR=Mid(Pass, i, 1)
      Codigo=Mid(Clave, ((i-1) Mod Len(Clave)) +1,1)
      Pass2= Pass2 & Right("0" & Hex(Asc(Codigo) Xor Asc(CAR)), 2)
Next i
Encripta = Pass2

I want to pass it to C #, which I take it to so far

public string Encripta(string Pass)
        {
            string Clave;
            int i;
            string Pass2;
            string CAR;
            string Codigo;
            Clave = "%ü&/@#$A";
            Pass2 = "";
            for (i = 1; (i <= Pass.Length); i++)
            {
                CAR = Pass.Substring((i - 1), 1);
                Codigo = Clave.Substring(((i - 1) % Clave.Length), 1);

            }

            return Pass2;
        }

but so far I can not understand the last line, what would be the equivalence of this line in C #

Pass2= Pass2 & Right("0" & Hex(Asc(Codigo) Xor Asc(CAR)), 2)
    
asked by Baker1562 29.04.2018 в 20:24
source

1 answer

1

I think it's like this:

var substr = "0" + ((int) Codigo ^ (int) CAR).ToString("X");
Pass2 += substr.Substring(substr.Length - 2);
    
answered by 29.04.2018 / 23:20
source