PDA

View Full Version : سوال: نحوه ی کار با SecureString



Ahmad-Agha
جمعه 05 دی 1393, 14:05 عصر
با سلام من میخوام که از کاربر پسورد دریافت کنم برای شرط هاش مشکل دارم اگه میشه راهنمایی ؟؟


using System;

using System.Security;



namespace ConsoleApplication42

{

class Program

{

public static SecureString getPassword()

{

SecureString pwd=new SecureString();

while (true)

{

ConsoleKeyInfo i;

i = Console.ReadKey(true);

if ((Convert.ToInt32(i.Key) >= 65) & (Convert.ToInt32(i.Key) <= 90))

{

pwd.AppendChar(i.KeyChar);

Console.Write("*");

}



if (i.Key == ConsoleKey.Escape)

{

break;

}

else if (i.Key == ConsoleKey.Backspace)

{

if (pwd.Length > 0)

{

pwd.RemoveAt(pwd.Length - 1);

Console.Write("\b \b");

}

}

else

{



}





}

return pwd;

}

static void Main(string[] args)

{

getPassword();

}

}

}

}

Ahmad-Agha
جمعه 05 دی 1393, 22:36 عصر
واقعا که
یعنی خیلی کار داره که یه جواب بدین


:تشویق:
دستتون درد نکنه