public static LoginInfo Load(byte[] data, EncryptKey Key) { using (MemoryStream ms = new MemoryStream(data)) using (BinaryReader br = new BinaryReader(ms)) { LoginInfo li = new LoginInfo(); li.name = br.ReadString(); int length = br.ReadInt32(); li.password = new EncryptedPassword(br.ReadBytes(length),Key); return li; } }
/// <summary> /// Create a new login info /// </summary> /// <returns> /// The LoginInfo /// </returns> /// <param name='Username'> /// Username. /// </param> /// <param name='Password'> /// Password. /// </param> public static LoginInfo CreateLogin(string Username, string Password) { EncryptedPassword ePass = EncryptedPassword.Encrypt(Password, key); LoginInfo loginInfo = new LoginInfo(Username, ePass); Logger.Write("Created new login {0}".format(Username)); return loginInfo; }
/// <summary> /// Register the specified Login to the list. /// </summary> /// <param name='Login'> /// Login. /// </param> public static void Register(LoginInfo Login) { if(logins.Any((li) => li.Name != Login.Name)) { Logger.Write("Given logininfo: {0} allready in list, ignoring".format(Login.Name)); } logins.Add(Login); }