Ver Mensaje Individual
  #177 (permalink)  
Antiguo 21/09/2010, 15:48
scorpionsdd
 
Fecha de Ingreso: septiembre-2010
Mensajes: 18
Antigüedad: 14 años, 2 meses
Puntos: 0
Respuesta: Factura electroncia sat mexico

private static int GetIntegerSize(BinaryReader binr)
{

byte bt = 0;

byte lowbyte = 0x00;

byte highbyte = 0x00;

int count = 0;

bt = binr.ReadByte();

if (bt != 0x02) //expect integer

return 0;

bt = binr.ReadByte();



if (bt == 0x81)

count = binr.ReadByte(); // data size in next byte

else

if (bt == 0x82)
{

highbyte = binr.ReadByte(); // data size in next 2 bytes

lowbyte = binr.ReadByte();

byte[] modint = { lowbyte, highbyte, 0x00, 0x00 };

count = BitConverter.ToInt32(modint, 0);

}

else
{

count = bt; // we already have the data size

}







while (binr.ReadByte() == 0x00)
{ //remove high order zeros in data

count -= 1;

}

binr.BaseStream.Seek(-1, SeekOrigin.Current); //last ReadByte wasn't a removed zero, so back up a byte

return count;

}

private static void showBytes(String info, byte[] data)
{

Console.WriteLine("{0} [{1} bytes]", info, data.Length);

for (int i = 1; i <= data.Length; i++)
{

Console.Write("{0:X2} ", data[i - 1]);

if (i % 16 == 0)

Console.WriteLine();

}

Console.WriteLine("\n\n");

}

private static SecureString GetSecPswd(String prompt)
{

SecureString password = new SecureString();



Console.ForegroundColor = ConsoleColor.Gray;

Console.Write(prompt);

Console.ForegroundColor = ConsoleColor.Magenta;



while (true)
{

ConsoleKeyInfo cki = Console.ReadKey(true);

if (cki.Key == ConsoleKey.Enter)
{

Console.ForegroundColor = ConsoleColor.Gray;

Console.WriteLine();

return password;

}

else if (cki.Key == ConsoleKey.Backspace)
{

// remove the last asterisk from the screen...

if (password.Length > 0)
{

Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);

Console.Write(" ");

Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);

password.RemoveAt(password.Length - 1);

}

}

else if (cki.Key == ConsoleKey.Escape)
{

Console.ForegroundColor = ConsoleColor.Gray;

Console.WriteLine();

return password;

}

else if (Char.IsLetterOrDigit(cki.KeyChar) || Char.IsSymbol(cki.KeyChar))
{

if (password.Length < 20)
{

password.AppendChar(cki.KeyChar);

Console.Write("*");

}

else
{

Console.Beep();

}

}

else
{

Console.Beep();

}

}

}