Metodo que Adiciona la operación XOR a una cadena Hexadecimal c# .net

#region Adiconar operación XOR a una cadena En Hexadecimal

/// <summary>

/// Adiciona la operación XOR a una cadena Hexadecimal

/// </summary>

/// <param name="strNumHexa">Número Hexadecimal</param>

/// <returns>valor de la operación XOR</returns>

public string strAddXOR(string strNumHexa)

{

int i=0;

long lSuma = 0;

long lngLongitud=0;

string strSumaxOR =""; 

try

{

lngLongitud = strNumHexa.Length;

if (lngLongitud < 2)

return "";

for (i = 0; i < lngLongitud; i = i + 2)

lSuma = lSuma ^ Convert.ToInt64("0x" + strNumHexa.Trim().Substring(i, 2), 16);

 

strSumaxOR = Uri.HexEscape((char)lSuma);

strSumaxOR = strSumaxOR.Substring(strSumaxOR.Length – 2, 2);

return strSumaxOR;

}

catch (Exception ex)

{

throw new Exception(ex.Message);

}

}

#endregion

Adiconar operación XOR a una cadena En Hexadecimal

About omaracostacasas

ING SOFTWARE
This entry was posted in Microsoft .NET. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s